-
dynamic sql ..pls help
declare @fullname varchar(200)
declare @sqlstmt nvarchar(2000)
declare @from varchar(200)
select @fullname='nm_last'","'wpat.nm_first'
select @from =' from w_patient wpat'
set @sqlstmt=N'select '+ @fullname + @from
EXEC sp_executesql @sqlstmt
This give error...
-
Hi,
The error is on the following line, it complaining about the comma within the double quotes:
select @fullname='nm_last'","'wpat.nm_first'
Since its a string you'll need to either:
a) have the whole column(s) within a string eg,
select @fullname='nm_last, wpat.nm_first'
b) concatenate the strings. eg,
select @fullname=='nm_last' + ',' + 'wpat.nm_first'
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|