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 2005 Forums
 Transact-SQL (2005)
 Concantenate

Author  Topic 

ljp099
Yak Posting Veteran

79 Posts

Posted - 2007-10-14 : 19:03:15
Im trying to concatenate a variable to a value generated from a Select statment.

Below is the Select statment I have now:

INSERT INTO @ResearchDocuments (ID) SELECT ParamValues.ID.value('.','VARCHAR(20)') FROM @Ids.nodes('/Collection/Content/ID') as ParamValues(ID)


This statement retrieves numbers values, such as: 990, 991, 992

What I need to do is append the number, 1033, to the beginning of these values, so that the numbers look like this: 1033990, 1033991, 1033992


I tried something like this, but couldnt get it to work:

DECLARE @lang varchar(100)
SET @lang = '1033'

INSERT INTO @ResearchDocuments (ID) @lang + SELECT ParamValues.ID.value('.','VARCHAR(20)') FROM @Ids.nodes('/Collection/Content/ID') as ParamValues(ID)

Any help would be appreciated.

rmiao
Master Smack Fu Yak Hacker

7266 Posts

Posted - 2007-10-14 : 20:24:14
Tried this?

INSERT INTO @ResearchDocuments (ID) SELECT @lang + ParamValues.ID.value('.','VARCHAR(20)') FROM @Ids.nodes('/Collection/Content/ID') as ParamValues(ID)
Go to Top of Page
   

- Advertisement -