Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 contatenate string

Author  Topic 

esthera
Master Smack Fu Yak Hacker

1410 Posts

Posted - 2011-08-15 : 02:25:05
what is wrong with this code

select @reasondeleted = 'deleted(deleted in stage' + @stage + ')'

flamblaster
Constraint Violating Yak Guru

384 Posts

Posted - 2011-08-15 : 02:27:33
What is the error? What is the datatype for @stage? For example, if @stage is a numeric datatype, you would have to convert it to a character before concatenating.
Go to Top of Page

esthera
Master Smack Fu Yak Hacker

1410 Posts

Posted - 2011-08-15 : 02:45:08
stage is a nvarchar(50)

error is Incorrect syntax near '+'.
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2011-08-15 : 02:54:19
I don't see anything wrong with that.

Are you sure the error is from that line ?


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

flamblaster
Constraint Violating Yak Guru

384 Posts

Posted - 2011-08-15 : 02:55:20
Without seeing the rest of your query, it would be hard to say.

I ran:

declare @stage nvarchar(50)
set @stage='setting sample data to test'

select 'deleted(deleted in stage' + @stage + ')'

Results:
deleted(deleted in stagesetting sample data to test)

Are you trying to execute @stage? Ie, is @stage a query in itself? Or just a set value?
Go to Top of Page
   

- Advertisement -