sql server - Stored Procedure doesn't work, manual update works fine - why? -


so when executing sql below following: string or binary data truncated.

exec sp_goodswelcomenotification 'd84be19b-be86-4a38-958b-e6d786cc27db' 

the stored procedure follow:

alter proc [dbo].[sp_goodswelcomenotification]( @itemguid varchar(50) )  declare @productcode varchar(50), @parentguid varchar(100)     set @productcode = 'select idx37 iwfaccountopening idx1!='' , idx6=' + @itemguid     set @parentguid = 'select idx134 iwfaccountopening idx1!='' , idx6=' + @itemguid  begin transaction     insert notificationtable     values(650, @productcode, @parentguid, 'pending','','','y','y',@itemguid,0,'','') commit transaction   

when execute insert statement manually executes fine:

insert notificationtable     values(650, 'bv-tkm-0000068-02', '241c8abc-5f95-4c35-9405-d6adfc8e2f55', 'pending','','','y','y','d84be19b-be86-4a38-958b-e6d786cc27db',0,'','') 

where going wrong?

this syntax incorrect:

set @productcode = 'select idx37 iwfaccountopening idx1!='' , idx6=' + @itemguid set @parentguid = 'select idx134 iwfaccountopening idx1!='' , idx6=' + @itemguid 

i think you're looking for:

select @productcode = idx37 iwfaccountopening idx1!='' , idx6=@itemguid select @parentguid = idx134 iwfaccountopening idx1!='' , idx6=@itemguid 

you're assigning selectstatement variables, rather result of select statements

or more simple query be:

select      @productcode = idx37,     @parentguid = idx134      iwfaccountopening       idx1!=''      , idx6=@itemguid 

Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -