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
 Other SQL Server Topics (2005)
 display 2 fields as 1

Author  Topic 

taunt
Posting Yak Master

128 Posts

Posted - 2011-10-06 : 15:30:38
Hello how do you display in SSMS two different fields example onedata & twodata so they would show up together?

select onedata, twodata
from items

always has to different columns. I need it to display in 1 column.

Thanks

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-10-06 : 15:33:46
Not sure how you want to format it, but here's an example with a space in between

select onedata + ' ' + twodata as newname
from items

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

taunt
Posting Yak Master

128 Posts

Posted - 2011-10-06 : 15:52:40
quote:
Originally posted by tkizer

Not sure how you want to format it, but here's an example with a space in between

select onedata + ' ' + twodata as newname
from items

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog



Sorry forgot to metion that the two fields are different types. one is a nvarchar the other numeric.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-10-06 : 15:56:05
Then you'll need to convert to nvarchar.

How do you want to format it?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

taunt
Posting Yak Master

128 Posts

Posted - 2011-10-06 : 16:54:03
quote:
Originally posted by tkizer

Then you'll need to convert to nvarchar.

How do you want to format it?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog



nvarchar(15)

Thanks
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-10-06 : 16:55:08
How do you want to format the output? A space in between?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

taunt
Posting Yak Master

128 Posts

Posted - 2011-10-06 : 17:00:43
quote:
Originally posted by tkizer

How do you want to format the output? A space in between?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog



No space just onedata followed by twodata.

Thanks
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-10-06 : 17:02:26
select onedata + convert(nvarchar(20), twodata) as newname
from items

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

taunt
Posting Yak Master

128 Posts

Posted - 2011-10-06 : 17:05:49
quote:
Originally posted by tkizer

select onedata + convert(nvarchar(20), twodata) as newname
from items

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog



Works perfect!

Thanks
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-10-06 : 17:08:41
You're welcome, glad to help.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -