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
 General SQL Server Forums
 New to SQL Server Programming
 Ltrim problem

Author  Topic 

dim
Yak Posting Veteran

57 Posts

Posted - 2010-09-17 : 10:19:23
Hi,

I have a requirement wherein I need to concatenate two columns. The columns are of different datatype so I converted them to a standard char data type . The cncatenation works fine but it shows un needed space between the two column values .

dbo.vw2_Dim_Date.Month_Name + cast(ltrim (dbo.vw2_Dim_Date.Calendar_Year) as varchar)

The output that I get is

May 2010

I do not want so much of a space between the two values. Please let me know on this.

Thank You,





Dp

rohitvishwakarma
Posting Yak Master

232 Posts

Posted - 2010-09-17 : 10:24:28
RTRIM(dbo.vw2_Dim_Date.Month_Name) + cast(ltrim (dbo.vw2_Dim_Date.Calendar_Year) as varchar)
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-09-17 : 11:55:16
quote:
Originally posted by rohitvishwakarma

RTRIM(dbo.vw2_Dim_Date.Month_Name) + cast(ltrim (dbo.vw2_Dim_Date.Calendar_Year) as varchar)


always specify a length when you're casting to varchar

http://visakhm.blogspot.com/2010/02/importance-of-specifying-length-in.html

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

dim
Yak Posting Veteran

57 Posts

Posted - 2010-09-17 : 13:05:03
Thank You rohitvishwakarma ...it worked
RTRIM(dbo.vw2_Dim_Date.Month_Name) + cast(ltrim (dbo.vw2_Dim_Date.Calendar_Year) as varchar)

Dp
Go to Top of Page
   

- Advertisement -