Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
Log in  ::  Register  ::  Not logged in
Home       Members    Calendar    Who's On

Add to briefcase ««12

Spiltting columns in sql 2008 Expand / Collapse
Posted Friday, October 5, 2012 1:49 AM



Group: General Forum Members
Last Login: Today @ 2:21 AM
Points: 7,766, Visits: 16,387
Trout (10/2/2012)
hello i have one column that I need split into two, the colum records age value, and the name of the colum is ageatdeath

results for eg are:

What about infants? Is it always 'years' or does your data include 'months' or 'days'?

“Write the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.” - Gail Shaw

For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
Exploring Recursive CTEs by Example Dwain Camps
Post #1368862
Posted Friday, October 5, 2012 8:17 AM


Group: General Forum Members
Last Login: Sunday, November 15, 2015 10:02 AM
Points: 196, Visits: 93
kapil190588 (10/5/2012)
Hi vivek,

SELECT SUBSTRING(ageatdeath,0,CHARINDEX('Y',ageatdeath,0)) AS AGE_VAL,
SUBSTRING(ageatdeath,CHARINDEX('Y',ageatdeath,0),LEN(ageatdeath)) AS AGE_UNIT

this code also works fine.

Your welcome dude
Post #1369086
Posted Friday, October 5, 2012 8:20 AM



Group: General Forum Members
Last Login: Wednesday, November 25, 2015 11:22 PM
Points: 2,113, Visits: 2,686

To get quick answer follow this link:
Post #1369089
« Prev Topic | Next Topic »

Add to briefcase ««12

Permissions Expand / Collapse