Please start any new threads on our new site at http://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

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

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

hbadministrator
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'

SwePeso
Patron Saint of Lost Yaks

Sweden
30421 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

visakh16
Very Important crosS Applying yaK Herder

India
52326 Posts

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

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


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
  Previous Topic Topic Next 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.04 seconds. Powered By: Snitz Forums 2000