Log in
::
Register
::
Not logged in
Home
Tags
Articles
Editorials
Stairways
Forums
Scripts
Videos
Blogs
QotD
Books
Ask SSC
SQL Jobs
Training
Authors
About us
Contact us
Newsletters
Write for us
Recent Posts
Recent Posts
Popular Topics
Popular Topics
Home
Search
Members
Calendar
Who's On
Home
»
SQL Server 2005
»
Development
»
Urgent development question
14 posts, Page 1 of 2
1
2
»»
Urgent development question
Rate Topic
Display Mode
Topic Options
Author
Message
RPSql
RPSql
Posted Monday, January 25, 2010 9:53 AM
Old Hand
Group: General Forum Members
Last Login: Tuesday, April 30, 2013 7:10 AM
Points: 322,
Visits: 368
urgent development question:
i have a table which contains following columns:
name,
student id,
subjects
in subjects column we have subjects taken by each student seperated by semicolumn.i.e. "english;social study;crafts" etc.
now, curre, I want output table which is seperated by each subject...i.e.
before
------
name | student id | subjects
stdA| 123| english;social study
stdB| 234| social study;crafts
After
-----
name | student id | subjects
stdA| 123| english
stdA| 123| social study
stdB| 234| social study
stdB| 234| social crafts
....
Please help me as this is urgent.
Thanks.
Post #853117
GilaMonster
GilaMonster
Posted Monday, January 25, 2010 10:07 AM
SSC-Dedicated
Group: General Forum Members
Last Login: Today @ 4:30 AM
Points: 37,742,
Visits: 30,021
Why is this urgent? Homework with an upcoming deadline?
Please post table definitions, sample data and desired output. Read this to see the best way to post this to get quick responses.
http://www.sqlservercentral.com/articles/Best+Practices/61537/
Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
SQL In The Wild
: Discussions on DB performance with occasional diversions into recoverability
We walk in the dark places no others will enter
We stand on the bridge and no one may pass
Post #853137
Steve Jones - SSC Editor
Steve Jones - SSC Editor
Posted Monday, January 25, 2010 10:21 AM
SSC-Dedicated
Group: Administrators
Last Login: Yesterday @ 3:30 PM
Points: 31,436,
Visits: 13,751
We don't do homework questions. We are happy to help you figure things you, but you need to make an attempt to get some initial work done and show some code you've written.
Follow me on Twitter:
@way0utwest
Forum Etiquette: How to post data/code on a forum to get the best help
Post #853153
RPSql
RPSql
Posted Monday, January 25, 2010 10:24 AM
Old Hand
Group: General Forum Members
Last Login: Tuesday, April 30, 2013 7:10 AM
Points: 322,
Visits: 368
I didn't submitted the correct data as I don't want to send company data out...Next time I will make sure to put question in right format...sorry this time...Plz let me know if anyone has any idea...Thanks in advance...
Post #853155
SQLRNNR
SQLRNNR
Posted Monday, January 25, 2010 10:30 AM
SSCoach
Group: General Forum Members
Last Login: Yesterday @ 10:25 AM
Points: 18,754,
Visits: 12,337
Here is a thread that may help you find your solution. You will still need to look at the code and determine how to adapt it to your situation. Thus no direct code answer, but an answer as to how to find your answer
http://www.sqlservercentral.com/Forums/Topic845680-338-1.aspx
Jason
AKA CirqueDeSQLeil
I have given a name to my pain...
MCM SQL Server 2008
SQL RNNR
Posting Performance Based Questions - Gail Shaw
Posting Data Etiquette - Jeff Moden
Hidden RBAR - Jeff Moden
VLFs and the Tran Log - Kimberly Tripp
Post #853160
Nabha
Nabha
Posted Monday, January 25, 2010 10:39 AM
Mr or Mrs. 500
Group: General Forum Members
Last Login: Tuesday, August 02, 2011 3:36 AM
Points: 579,
Visits: 1,803
RPSql (1/25/2010)
I didn't submitted the correct data as I don't want to send company data out...Next time I will make sure to put question in right format...sorry this time...Plz let me know if anyone has any idea...Thanks in advance...
Even the same data that you posted would do but in a consumable format as suggested by Gail
---------------------------------------------------------------------------------
Post #853168
Greg Edwards-268690
Greg Edwards-268690
Posted Monday, January 25, 2010 11:18 AM
Right there with Babe
Group: General Forum Members
Last Login: Yesterday @ 10:09 AM
Points: 789,
Visits: 5,198
Just a thought...
If this is development, you may want to review the design.
Having a table for Subject ( with just a Code and Description for each Subject ) might allow you to more naturally get to the results you are seeking.
Say data was populated from a web form, would you have a drop down with every available combination of subects? Or allow freeform text to be entered? And then how would you validate user input?
Greg E
Post #853188
GilaMonster
GilaMonster
Posted Monday, January 25, 2010 12:03 PM
SSC-Dedicated
Group: General Forum Members
Last Login: Today @ 4:30 AM
Points: 37,742,
Visits: 30,021
Greg Edwards-268690 (1/25/2010)
Just a thought...
If this is development, you may want to review the design.
Absolutely. Comma-delimited lists in a column are a violation of 1st Normal Form and are an absolute pain to deal with. This is the easy part, trying to add or remove 'subjects' from the list is far harder.
Take the time to properly normalise the table, and you won't have problems like this one.
Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
SQL In The Wild
: Discussions on DB performance with occasional diversions into recoverability
We walk in the dark places no others will enter
We stand on the bridge and no one may pass
Post #853213
SQLRNNR
SQLRNNR
Posted Monday, January 25, 2010 12:47 PM
SSCoach
Group: General Forum Members
Last Login: Yesterday @ 10:25 AM
Points: 18,754,
Visits: 12,337
GilaMonster (1/25/2010)
Greg Edwards-268690 (1/25/2010)
Just a thought...
If this is development, you may want to review the design.
Absolutely. Comma-delimited lists in a column are a violation of 1st Normal Form and are an absolute pain to deal with. This is the easy part, trying to add or remove 'subjects' from the list is far harder.
Take the time to properly normalise the table, and you won't have problems like this one.
Taking it a step further - normalize any tables that have any (comma,semi-colon, etc) delimited columns
Jason
AKA CirqueDeSQLeil
I have given a name to my pain...
MCM SQL Server 2008
SQL RNNR
Posting Performance Based Questions - Gail Shaw
Posting Data Etiquette - Jeff Moden
Hidden RBAR - Jeff Moden
VLFs and the Tran Log - Kimberly Tripp
Post #853242
GSquared
GSquared
Posted Monday, January 25, 2010 1:36 PM
SSCoach
Group: General Forum Members
Last Login: Tuesday, May 21, 2013 1:55 PM
Points: 15,442,
Visits: 9,571
GilaMonster (1/25/2010)
Greg Edwards-268690 (1/25/2010)
Just a thought...
If this is development, you may want to review the design.
Absolutely. Comma-delimited lists in a column are a violation of 1st Normal Form and are an absolute pain to deal with. This is the easy part, trying to add or remove 'subjects' from the list is far harder.
Take the time to properly normalise the table, and you won't have problems like this one.
Even worse is if a subject needs to be renamed. What if "English" becomes "Language Arts" (as it did for me while I was in high school)? Can't just simply "replace" it, because you could also have a class on "Advanced English Literature", or "English as a Second Language", and suddenly you'd mess those up. Can become quite tricky.
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
Post #853282
« Prev Topic
|
Next Topic »
14 posts, Page 1 of 2
1
2
»»
Permissions
You
cannot
post new topics.
You
cannot
post topic replies.
You
cannot
post new polls.
You
cannot
post replies to polls.
You
cannot
edit your own topics.
You
cannot
delete your own topics.
You
cannot
edit other topics.
You
cannot
delete other topics.
You
cannot
edit your own posts.
You
cannot
edit other posts.
You
cannot
delete your own posts.
You
cannot
delete other posts.
You
cannot
post events.
You
cannot
edit your own events.
You
cannot
edit other events.
You
cannot
delete your own events.
You
cannot
delete other events.
You
cannot
send private messages.
You
cannot
send emails.
You
may
read topics.
You
cannot
rate topics.
You
cannot
vote within polls.
You
cannot
upload attachments.
You
may
download attachments.
You
cannot
post HTML code.
You
cannot
edit HTML code.
You
cannot
post IFCode.
You
cannot
post JavaScript.
You
cannot
post EmotIcons.
You
cannot
post or upload images.
Copyright © 2002-2013 Simple Talk Publishing. All Rights Reserved.
Privacy Policy.
Terms of Use.
Report Abuse.