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 2008 Forums
 Transact-SQL (2008)
 Easy Case when

Author  Topic 

hbadministrator
Posting Yak Master

120 Posts

Posted - 2013-07-10 : 11:17:24
I am trying to do an easy Case When I hope at least. I am looking at if quote-no has 6 values 123456 keep it as is if it only has 5 int's then add a 0 first 012345.

CASE WHEN [dbo].[job].[Quote-no] = '%%%%%%' THEN [dbo].[job].[Quote-no] ELSE [dbo].[job].[Quote-no] = '0%%%%%'End as 'Quote-no'

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2013-07-10 : 11:29:25
RIGHT('000000' + CAST([Quote-No] AS VARCHAR(6)), 6) AS [Quote-No]



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-07-10 : 13:11:29
[code]
REPLACE(STR([Quote-No],6),' ','0')
[/code]

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
   

- Advertisement -