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

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Easy Case when
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Posting Yak Master

120 Posts

Posted - 07/10/2013 :  11:17:24  Show Profile  Reply with Quote
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'

Patron Saint of Lost Yaks

30407 Posts

Posted - 07/10/2013 :  11:29:25  Show Profile  Visit SwePeso's Homepage  Reply with Quote
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

Very Important crosS Applying yaK Herder

52326 Posts

Posted - 07/10/2013 :  13:11:29  Show Profile  Reply with Quote

REPLACE(STR([Quote-No],6),' ','0')

SQL Server MVP
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