tsql - SQL Server User Defined Table Types and BCP Export -


i can't seem script work. i'm getting following error:

msg 137, level 16, state 1, line 14 must declare scalar variable "@tvp_glicu".

can tell me missing?

declare @tvp_glicu tvp_glicu  declare @cmd varchar(500) declare @timestamp nvarchar(100) = replace((convert(varchar(25), getdate(), 121)),':','')  --insert batch numbers in user defined table types  insert @tvp_glicu (id) values ('563704') insert @tvp_glicu (id) values ('498721')  --select *  --from @tvp_glicu   set @cmd = 'bcp "execute [f0902].[d365o].[get-f0911newrecords]'+@tvp_glicu+'" queryout "d:\d365o\datasource\f0911\'+@timestamp+'.csv" -c -t\^, -t -s' + @@servername + '' execute master..xp_cmdshell @cmd 

you can't refer table variable bcp created outside scope of query parameter. when bcp executed, creates new session , scope of table variables limited session created table variable.


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -