Hi,
Have a query which works perfectly and now need to assign it to a variable. How do you do that ? Am getting errors, is it not allowed with openquery ?
For example I need to store the results of the exec below to a variable.
Thanks, Steve
Declare @query varchar(8000)
Declare @pID varchar(20)
Declare @pLINE varchar(5)
Declare @oDESIREDRCVDATE varchar(10)
Declare @pSTATUSX varchar(1)
Declare @pSTATUSC varchar(1)
Set @pID='NYDELLTEST'
Set @pLINE='1'
Set @oDESIREDRCVDATE='2006-03-25 00:00:00.000'
Set @pSTATUSX='X'
Set @pSTATUSC='C'
set @query = 'UPDATE OPENQUERY(VMFG, ''SELECT DESIRED_RECV_DATE from PURC_ORDER_LINE WHERE PURC_ORDER_ID=''''' + @pID + ''''' AND LINE_NO=''''' + @pLINE + ''''''')'
set @query = @query + 'SET DESIRED_RECV_DATE = '''+@oDESIREDRCVDATE + ''''
exec(@query)
Have a query which works perfectly and now need to assign it to a variable. How do you do that ? Am getting errors, is it not allowed with openquery ?
For example I need to store the results of the exec below to a variable.
Thanks, Steve
Declare @query varchar(8000)
Declare @pID varchar(20)
Declare @pLINE varchar(5)
Declare @oDESIREDRCVDATE varchar(10)
Declare @pSTATUSX varchar(1)
Declare @pSTATUSC varchar(1)
Set @pID='NYDELLTEST'
Set @pLINE='1'
Set @oDESIREDRCVDATE='2006-03-25 00:00:00.000'
Set @pSTATUSX='X'
Set @pSTATUSC='C'
set @query = 'UPDATE OPENQUERY(VMFG, ''SELECT DESIRED_RECV_DATE from PURC_ORDER_LINE WHERE PURC_ORDER_ID=''''' + @pID + ''''' AND LINE_NO=''''' + @pLINE + ''''''')'
set @query = @query + 'SET DESIRED_RECV_DATE = '''+@oDESIREDRCVDATE + ''''
exec(@query)