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
 Express Edition and Compact Edition (2005)
 Merge two columns

Author  Topic 

risa.86
Starting Member

3 Posts

Posted - 2007-06-16 : 04:05:05
I want to combine a column with Id and other with Name.

For eg: If Id is 01 and Name is 'Tom', the output should be 01-Tom.

I am not able to execute it using || or CONCAT since Id has the data type int and Name is a string.

Do you have a solution?

`RG`

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-06-16 : 04:07:08
[code]select right('00' + convert(varchar(2), Id), 2) + '-' + Name[/code]


KH

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-06-16 : 08:38:43
<<
I am not able to execute it using || or CONCAT since Id has the data type int and Name is a string.
>>

This is SQL Server Forum
If your question is related to ORACLE then post at Oracle related Forum

Madhivanan

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

risa.86
Starting Member

3 Posts

Posted - 2007-06-17 : 07:56:04
Thanks for your help. Btw didnt know Sql queries in SQl Server and Oracle were different!
quote:
Originally posted by madhivanan

<<
I am not able to execute it using || or CONCAT since Id has the data type int and Name is a string.
>>

This is SQL Server Forum
If your question is related to ORACLE then post at Oracle related Forum

Madhivanan

Failing to plan is Planning to fail



`RG`
Go to Top of Page

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2007-06-17 : 08:22:56
Sql SErver queries are called Transact SQL while oracle is called PL SQL
Go to Top of Page
   

- Advertisement -