August 31, 2012 at 1:06 am
I have this table
CSN NAME LOCATION TYPE
MO-550 IFA Comapny MO-450 SIPP
1-275 BGT Company NN-SP Company
1-2956 BLQ Company SSFT TRUST
How do i write a query that returns a NAME concatenated with it's CSN
August 31, 2012 at 1:11 am
hoseam (8/31/2012)
I have this tableCSN NAME LOCATION TYPE
MO-550 IFA Comapny MO-450 SIPP
1-275 BGT Company NN-SP Company
1-2956 BLQ Company SSFT TRUST
How do i write a query that returns a NAME concatenated with it's CSN
SELECT (CAST(tb.[NAME] AS VARCHAR(MAX)) + CAST(tb.[CSN] AS VARCHAR(MAX))) [result]
FROM dbo.yourTable tb
I have used VARCHAR(MAX) and explicit CASTs in the absence of a table definition.
---
Note to developers:Want to get the best help? Click here https://www.sqlservercentral.com/articles/forum-etiquette-how-to-post-datacode-on-a-forum-to-get-the-best-help (Jeff Moden)
My blog: http://uksqldba.blogspot.com
Visit http://www.DerekColley.co.uk to find out more about me.
August 31, 2012 at 1:14 am
The '+' operator does string concatenation in T-SQL. Assuming CSN and Name are both string columns in your table. You can:
SELECT CSN + ' ' + [Name] AS CSNName
FROM dbo.YourTable;
HTH,
Rob
August 31, 2012 at 1:53 am
Thank you guys
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply