SQL Server Forums
Profile | Register | 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)
 replacement for substring
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

causative
Starting Member

Poland
2 Posts

Posted - 11/13/2013 :  11:23:29  Show Profile  Reply with Quote
Hello
My postcode format in my database is: 20470 and I use the following query to transform it to format: 20-470

((substring((STR(postcode)),6,2)+'-'+substring((STR(postcode)),8,3)))

Is it possible to do in another way?

TG
Flowing Fount of Yak Knowledge

USA
5943 Posts

Posted - 11/13/2013 :  11:33:44  Show Profile  Reply with Quote
one way:
stuff(postcode, 3, 0, '-')

Be One with the Optimizer
TG
Go to Top of Page

causative
Starting Member

Poland
2 Posts

Posted - 11/13/2013 :  11:44:33  Show Profile  Reply with Quote
that is the point
thx a lot
Go to Top of Page

TG
Flowing Fount of Yak Knowledge

USA
5943 Posts

Posted - 11/13/2013 :  13:56:40  Show Profile  Reply with Quote
you're welcome. You should use books online often - it is very helpful for exploring things like this. For example here are string functions.

Be One with the Optimizer
TG
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.06 seconds. Powered By: Snitz Forums 2000