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)
 Concatenation

Author  Topic 

Steve2106
Posting Yak Master

183 Posts

Posted - 2007-06-28 : 10:15:40
Hi Guys,

Can you help please.

I need to concatenate to integers in to a string field. How do I do that? I have tried this but it is wrong.

Select ElementID + ' : ' + RequirementId as "ConCatField"
From tbMinimumRequirements

I know this is seriously wrong but I can't for the life of me think how to do it.

Thanks for your help.

Best Regards,

Steve.

Steve

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-06-28 : 10:18:24
Cast non varchar column to varchar

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-06-28 : 10:19:15
[code]SELECT CONVERT(varchar(10), ElementID) + ' : ' + CONVERT(varchar(10), RequirementId) AS "ConCatField"
FROM tbMinimumRequirements[/code]


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

Go to Top of Page

Steve2106
Posting Yak Master

183 Posts

Posted - 2007-06-28 : 10:24:47
Hi Guys,
I just came back here to tell you I had worked it out but as usual the help here is so quick you had beat me to it.
Thanks for your help, I appreciate you taking the time to help.

Best Regards,


Steve.

By the way this was my code.
Select convert(varchar(4),ElementID) + ':' + convert(varchar(4),RequirementId) as "ConCatField"
From tbMinimumRequirements

Steve
Go to Top of Page
   

- Advertisement -