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
 General SQL Server Forums
 New to SQL Server Programming
 column seperation
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

subhaoviya
Posting Yak Master

India
119 Posts

Posted - 06/22/2012 :  06:09:35  Show Profile  Reply with Quote

Declare @a varchar(50)
set @a='1234-76589'
how to produce resultset
a1 b1
1234 76589

webfred
Flowing Fount of Yak Knowledge

Germany
8529 Posts

Posted - 06/22/2012 :  07:08:16  Show Profile  Visit webfred's Homepage  Reply with Quote
Declare @a varchar(50)
set @a='1234-76589'
select
parsename(replace(@a,'-','.'),2) as a1,
parsename(replace(@a,'-','.'),1) as b1


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

subhaoviya
Posting Yak Master

India
119 Posts

Posted - 06/22/2012 :  07:27:45  Show Profile  Reply with Quote
thanks friend.

I found one more way

Declare @a varchar(50)
set @a='1234-76589'
select
substring(@a,0,CHARINDEX('-',@a)),
SUBSTRING(@a,CHARINDEX('-',@a)+1,len(@a)-1)
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.03 seconds. Powered By: Snitz Forums 2000