User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the MS SQL section within the Web Development category of DaniWeb, a massive community of 427,804 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,774 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our MS SQL advertiser: Programming Forums

New line Character in column alias

Join Date: Jan 2007
Location: Cincinnati, OH
Posts: 1
Reputation: szabogi is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
szabogi szabogi is offline Offline
Newbie Poster

Solution Re: New line Character in column alias

  #9  
Jan 17th, 2007
Here is some T-SQL code that should acheive your objective:

[code]
-- declare variables
DECLARE @vchColumnOutput varchar(200)
DECLARE @vchWorkCode varchar(100)
DECLARE @vchWorkNature varchar(100)
-- select data from tblWhatever into @variables
SELECT @vchWorkCode = work_code,
@vchWorkNature = work_nature
FROM tblWhatever
-- insert a carriage return between work_code and work_nature
SET @vchColumnOutput = @vchWorkCode +char(13)+ @vchWorkNature
-- display work code and work nature
SELECT @vchColumnOutput
[code]



Originally Posted by manishkaushik View Post
Hi Friends,

I have the following query, i am using the column alias by this way,
select work_Code as "Work Code",work_nature as "Work Nature" from sb_cm_work_nature

it works fine and i get this output.

Work Code Work Nature

1 External
2 DE-Sales
3 DE-Miscellaneous
4 DE-Equipments &Transport

But my requirement is to break the Column alias in two line with the new line character as follows

Work Work
Code Nature

1 External
2 DE-Sales
3 DE-Miscellaneous
4 DE-Equipments &Transport

Please guide me how can i proceed.
Thanks you so much.

Manish Kaushik
Reply With Quote  
All times are GMT -4. The time now is 2:19 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC