SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2005 Forums
 Express Edition and Compact Edition (2005)
 Merge two columns
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

risa.86
Starting Member

India
3 Posts

Posted - 06/16/2007 :  04:05:05  Show Profile  Reply with Quote
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)

Singapore
16746 Posts

Posted - 06/16/2007 :  04:07:08  Show Profile  Reply with Quote
select right('00' + convert(varchar(2), Id), 2) + '-' + Name



KH

Go to Top of Page

madhivanan
Premature Yak Congratulator

India
22460 Posts

Posted - 06/16/2007 :  08:38:43  Show Profile  Send madhivanan a Yahoo! Message  Reply with Quote
<<
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

India
3 Posts

Posted - 06/17/2007 :  07:56:04  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

Nigeria
2702 Posts

Posted - 06/17/2007 :  08:22:56  Show Profile  Reply with Quote
Sql SErver queries are called Transact SQL while oracle is called PL SQL
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000