August 22, 2006 at 9:25 am
Hi, I'm trying to duplicate the following code from a SP but using Dynamic SQL
select [JOHN BROWN] from [resource] where [date] BETWEEN @sDate1 AND @sDate2
What I've got so far is :
SET @CMD = 'SELECT @Rtn = [' + @ColName + '] from [Resource]' + ' where [date] between ''' + @sDate1 + ''' + and + ''' @sDate2 + ''''
exec sp_executesql @CMD,N'@Rtn varchar (200) out',@Status out
but I can't seem to get the correct syntax, can anyone help please. I also need it to return a record set
August 22, 2006 at 10:23 am
try this one
SET @CMD = 'SELECT [' + @ColName + '] from [Resource]' + ' where [date] between ''' + @sDate1 + ''' + and + ''' @sDate2 + ''''
exec sp_executesql @CMD
Rohit
August 23, 2006 at 5:11 am
many thanks Rohit, that works great
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy