sql - I have successfully created a scalar function, but get an error The multi-part identifier "dbo.unpivottest3" could not be bound -


my function:

create function [dbo].[unpivottest3]()  returns int begin    declare @colsunpivot nvarchar(max),            @query nvarchar(max)     --select particular columns      select @colsunpivot = stuff((select ',' + quotename(c.column_name)                                 information_schema.columns c                                 c.table_name = 'tblkri dump'                                    , c.column_name '%-20%'                                 xml path('')), 1, 1, '')     set @query = 'insert bi_dwh.tblkri_dump1 select  u.sector_name, u.lob_name, u.indicator_group_name, u.user_defined_indicator_id, u.indicator_name, u.indicator_description, u.classification, u.score_green_threshold, u.score_red_threshold, u.indicator_priority, u.indicator_how_to_acquire, u.cause, u.impact, u.action_plan, u.resolution_expected, u.resolution_target_date, u.no_resolution_reason, u.memo_last_updated, u.risk_category, u."risk_sub-category", u.updated_by, u.updated_on, u.score_1_red_2_amb_3_grn,  u.monthkey, u.value [bi_dwh].[tblkri dump]  unpivot (   value   monthkey in ('+ @colsunpivot +') ) u '     exec sp_executesql @query      return 0 end 


Comments

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -