Why can I not pass the results of a dynamic string query straight into a variable?
I have this query to find the max uid for a givern job run. I paramaterized the server name so that the table can be moved between servers for disaster recovery:
declare @destsvr varchar(30),
@file varchar(30),
@cmd varchar(300),
@marker Int
select @destsvr = '[PRD-005].Operations.DBO'
select @file = 'test1.txt'
select @cmd = ('select MAX(UID) FROM '+@destsvr+'.ProcessStatus Where SubApp = @File')
exec @cmd
This query qill return a UID that I want to assign to @Marker, thus allowing me to do updates later on in the process.
Other than inserting the results to a table, then assigning that value to my marker var, does anyone see any other way to get this uid out of the dynamic string and into a variable?
I have this query to find the max uid for a givern job run. I paramaterized the server name so that the table can be moved between servers for disaster recovery:
declare @destsvr varchar(30),
@file varchar(30),
@cmd varchar(300),
@marker Int
select @destsvr = '[PRD-005].Operations.DBO'
select @file = 'test1.txt'
select @cmd = ('select MAX(UID) FROM '+@destsvr+'.ProcessStatus Where SubApp = @File')
exec @cmd
This query qill return a UID that I want to assign to @Marker, thus allowing me to do updates later on in the process.
Other than inserting the results to a table, then assigning that value to my marker var, does anyone see any other way to get this uid out of the dynamic string and into a variable?