Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Isolate value through sql query

Status
Not open for further replies.

macsql1

Programmer
Jan 20, 2008
25
IN
Hi All,

I have a question. Using sql server 2005. A table with 3 column, where column1 contains data in numeric(1234)then one space followed by alphabets(Book).

I need to separate Column1 value to Column2 and Column3.

eg1.
Column1: 1234 Book
(Output )
Column2: 1234
Column3: Book

eg2.
Column1: 34 Bookself
(Output )
Column2: 34
Column3: Bookself

Here we have to differentiate value by SPACE between numeric value and alphabets value.

How to proceed. Thanks in advance.

-Mac
 
SELECT SUBSTRING(Column1,1,CHARINDEX(' ',Column1)) AS Column2
, SUBSTRING(Column1,CHARINDEX(' ',Column1)+1,999) AS Column3
FROM ...

r937.com | rudy.ca
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top