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
 General SQL Server Forums
 New to SQL Server Programming
 column seperation

Author  Topic 

subhaoviya
Posting Yak Master

135 Posts

Posted - 2012-06-22 : 06:09:35

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

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2012-06-22 : 07:08:16
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

135 Posts

Posted - 2012-06-22 : 07:27:45
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
   

- Advertisement -