SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


derived column


derived column

Author
Message
harri.reddy
harri.reddy
SSC-Enthusiastic
SSC-Enthusiastic (191 reputation)SSC-Enthusiastic (191 reputation)SSC-Enthusiastic (191 reputation)SSC-Enthusiastic (191 reputation)SSC-Enthusiastic (191 reputation)SSC-Enthusiastic (191 reputation)SSC-Enthusiastic (191 reputation)SSC-Enthusiastic (191 reputation)

Group: General Forum Members
Points: 191 Visits: 346
in my excel sheet i have 1 column

which contains name like


shah, anki S.
dogula nanacy
baskin brian B
waive, FRANCISCO p.
le, pinti
Leo, tomy


the first one is last name,firstname and middle initial

i need to seperate in all 3 column ,i am using derived column,but dont know expression.

please help me
Luis Cazares
Luis Cazares
SSCoach
SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)

Group: General Forum Members
Points: 16482 Visits: 19086
How about this? It might be expensive, but it's a solution.

WITH names( fullname) AS(
SELECT 'shah, anki S.' UNION ALL
SELECT 'dogula nanacy' UNION ALL
SELECT 'baskin brian B' UNION ALL
SELECT 'waive, FRANCISCO p.' UNION ALL
SELECT 'le, pinti' UNION ALL
SELECT 'Leo, tomy'),
names2 AS(
SELECT REPLACE(REPLACE(REPLACE(fullname, '.',''),',', ''), ' ', '.') AS formatname
FROM names
)
SELECT REVERSE( PARSENAME(REVERSE(formatname), 1)),
REVERSE( PARSENAME(REVERSE(formatname), 2)),
REVERSE( PARSENAME(REVERSE(formatname), 3))
FROM names2



Or you can do it all at once:

WITH names( fullname) AS(
SELECT 'shah, anki S.' UNION ALL
SELECT 'dogula nanacy' UNION ALL
SELECT 'baskin brian B' UNION ALL
SELECT 'waive, FRANCISCO p.' UNION ALL
SELECT 'le, pinti' UNION ALL
SELECT 'Leo, tomy'
)
SELECT REVERSE( PARSENAME(REVERSE(REPLACE(REPLACE(REPLACE(fullname, '.',''),',', ''), ' ', '.')), 1)),
REVERSE( PARSENAME(REVERSE(REPLACE(REPLACE(REPLACE(fullname, '.',''),',', ''), ' ', '.')), 2)),
REVERSE( PARSENAME(REVERSE(REPLACE(REPLACE(REPLACE(fullname, '.',''),',', ''), ' ', '.')), 3))
FROM names




Luis C.
General Disclaimer:
Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?


How to post data/code on a forum to get the best help: Option 1 / Option 2
harri.reddy
harri.reddy
SSC-Enthusiastic
SSC-Enthusiastic (191 reputation)SSC-Enthusiastic (191 reputation)SSC-Enthusiastic (191 reputation)SSC-Enthusiastic (191 reputation)SSC-Enthusiastic (191 reputation)SSC-Enthusiastic (191 reputation)SSC-Enthusiastic (191 reputation)SSC-Enthusiastic (191 reputation)

Group: General Forum Members
Points: 191 Visits: 346
i need derived column solution ,not sql
Phil Parkin
Phil Parkin
SSCoach
SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)

Group: General Forum Members
Points: 18411 Visits: 20424
harri.reddy (8/29/2012)
i need derived column solution ,not sql


Write out your detailed logic for breaking the column into three and we'll help with the solution. Might need a Script Component if it's complex - derived columns can only go so far.


Help us to help you. For better, quicker and more-focused answers to your questions, consider following the advice in this link.

If the answer to your question can be found with a brief Google search, please perform the search yourself, rather than expecting one of the SSC members to do it for you.

Please surround any code or links you post with the appropriate IFCode formatting tags. It helps readability a lot.
Luis Cazares
Luis Cazares
SSCoach
SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)

Group: General Forum Members
Points: 16482 Visits: 19086
I'm sorry, I didn't see the forum's name Blush


Luis C.
General Disclaimer:
Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?


How to post data/code on a forum to get the best help: Option 1 / Option 2
harri.reddy
harri.reddy
SSC-Enthusiastic
SSC-Enthusiastic (191 reputation)SSC-Enthusiastic (191 reputation)SSC-Enthusiastic (191 reputation)SSC-Enthusiastic (191 reputation)SSC-Enthusiastic (191 reputation)SSC-Enthusiastic (191 reputation)SSC-Enthusiastic (191 reputation)SSC-Enthusiastic (191 reputation)

Group: General Forum Members
Points: 191 Visits: 346
i am usinf this expression for my first column

REPLACE(SUBSTRING(product,1,FINDSTRING(product," ",1) + 0),","," ")

i need help for second and third.

please help me
Phil Parkin
Phil Parkin
SSCoach
SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)

Group: General Forum Members
Points: 18411 Visits: 20424
harri.reddy (8/29/2012)
i am usinf this expression for my first column

REPLACE(SUBSTRING(product,1,FINDSTRING(product," ",1) + 0),","," ")

i need help for second and third.

please help me


Not really what I asked for. What is your logic for dividing the second and third columns? It needs to accommodate all the variations in your data.


Help us to help you. For better, quicker and more-focused answers to your questions, consider following the advice in this link.

If the answer to your question can be found with a brief Google search, please perform the search yourself, rather than expecting one of the SSC members to do it for you.

Please surround any code or links you post with the appropriate IFCode formatting tags. It helps readability a lot.
harri.reddy
harri.reddy
SSC-Enthusiastic
SSC-Enthusiastic (191 reputation)SSC-Enthusiastic (191 reputation)SSC-Enthusiastic (191 reputation)SSC-Enthusiastic (191 reputation)SSC-Enthusiastic (191 reputation)SSC-Enthusiastic (191 reputation)SSC-Enthusiastic (191 reputation)SSC-Enthusiastic (191 reputation)

Group: General Forum Members
Points: 191 Visits: 346
i know ,it has so many variation.

what is the other way in ssis, i can achieve.

plz help me
Phil Parkin
Phil Parkin
SSCoach
SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)

Group: General Forum Members
Points: 18411 Visits: 20424
harri.reddy (8/29/2012)
i know ,it has so many variation.

what is the other way in ssis, i can achieve.

plz help me


Ah, you must mean the magic-wand component.


Help us to help you. For better, quicker and more-focused answers to your questions, consider following the advice in this link.

If the answer to your question can be found with a brief Google search, please perform the search yourself, rather than expecting one of the SSC members to do it for you.

Please surround any code or links you post with the appropriate IFCode formatting tags. It helps readability a lot.
n79799
n79799
Valued Member
Valued Member (59 reputation)Valued Member (59 reputation)Valued Member (59 reputation)Valued Member (59 reputation)Valued Member (59 reputation)Valued Member (59 reputation)Valued Member (59 reputation)Valued Member (59 reputation)

Group: General Forum Members
Points: 59 Visits: 122
This should help :
Have a derived col. Have three cols in there as (assume F1 is your excel col):

First_name
expression :SUBSTRING((REPLACE(F1,","," ")),1,FINDSTRING(F1," ",1))

Last_name
expression :
SUBSTRING(F1,FINDSTRING(F1," ",1) + 1,FINDSTRING(F1 + " "," ",2) - FINDSTRING(F1," ",1) - 1)

middle_name
expression :
(FINDSTRING(F1," ",2) > 0) ? REPLACE(SUBSTRING(F1,FINDSTRING(F1," ",2) + 1,FINDSTRING(F1 + " "," ",3) - FINDSTRING(F1," ",2) - 1),".","") : " "

Please let me know if this worked or not
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search