jung1975
asked on
concat in dynamic sql
How can I concat string in dynamic sql?
I need to put the below SQL in Dynamic sql
Select ID ,Question, answer, (question + ':' + answer) as Question_Text from table
where question = @question
I've tried somthing like below but i keep getting an error?
Declare @sql varchar(max)
set @sql = 'Select ID ,Question, answer, (question + ''':''' + answer) as Question_Text from table where question = ' + @Question + ''
Exec @sql
I need to put the below SQL in Dynamic sql
Select ID ,Question, answer, (question + ':' + answer) as Question_Text from table
where question = @question
I've tried somthing like below but i keep getting an error?
Declare @sql varchar(max)
set @sql = 'Select ID ,Question, answer, (question + ''':''' + answer) as Question_Text from table where question = ' + @Question + ''
Exec @sql
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.