p2p.wrox.com Forums

Need to download code?

View our list of code downloads.

Go Back   p2p.wrox.com Forums > Database > SQL Language
I forgot my password
Register Now
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
SQL Language SQL Language discussions not specific to a particular RDBMS program or vendor.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Language section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other programmers’ questions, win occasional prizes given to our best members, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 1st, 2009, 09:09 PM
Authorized User
Points: 54, Level: 1
Points: 54, Level: 1 Points: 54, Level: 1 Points: 54, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2006
Location: Texas, TX, USA.
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to devendar
Default Comma Separated One row into Multiple columns

CREATETABLE #Locations
(Name1 VARCHAR(100))
INSERTINTO #Locations values('Scott,M,36')
INSERTINTO #Locations values('Eric,M, 24')

I need Output three columns like

Name Group Age
Scott M 36
Eric M 24

Thanks in advance
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #2 (permalink)  
Old October 6th, 2009, 09:03 AM
Friend of Wrox
Points: 3,190, Level: 23
Points: 3,190, Level: 23 Points: 3,190, Level: 23 Points: 3,190, Level: 23
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Tehran, Iran
Posts: 926
Thanks: 0
Thanked 4 Times in 4 Posts
Send a message via Yahoo to melvik
Default

SELECT REPLACE(Name1 , ',', ' ')
__________________
Always[:)],
Hovik Melkomian.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #3 (permalink)  
Old October 7th, 2009, 03:24 AM
Friend of Wrox
Points: 5,054, Level: 30
Points: 5,054, Level: 30 Points: 5,054, Level: 30 Points: 5,054, Level: 30
Activity: 59%
Activity: 59% Activity: 59% Activity: 59%
 
Join Date: Jun 2008
Location: Snohomish, WA, USA
Posts: 1,378
Thanks: 3
Thanked 78 Times in 77 Posts
Default

Didn't you ask nearly identically this same question in another post and/or another forum????

If you didn't then your clone did.

Code:
CREATETABLE #Locations
(
  Name VARCHAR(100),
  Group VARCHAR(20),
  Age INT 
)
INSERTINTO #Locations values('Scott','M',36)
INSERTINTO #Locations values('Eric','M', 24)
...
If you WANT three fields, then CREATE three fields. The DB can't magically guess that you want your single value to suddenly become three. Especially when you created the table to only have one field.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #4 (permalink)  
Old October 7th, 2009, 03:26 AM
Friend of Wrox
Points: 5,054, Level: 30
Points: 5,054, Level: 30 Points: 5,054, Level: 30 Points: 5,054, Level: 30
Activity: 59%
Activity: 59% Activity: 59% Activity: 59%
 
Join Date: Jun 2008
Location: Snohomish, WA, USA
Posts: 1,378
Thanks: 3
Thanked 78 Times in 77 Posts
Default

Yes! You did!

Why didn't you READ the answer I gave you yesterday????

SQL Server 2008 Query (comma separated)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #5 (permalink)  
Old October 9th, 2009, 02:52 AM
Friend of Wrox
Points: 763, Level: 10
Points: 763, Level: 10 Points: 763, Level: 10 Points: 763, Level: 10
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2005
Location: OKC, OK, USA.
Posts: 218
Thanks: 1
Thanked 7 Times in 7 Posts
Default

Another Method is using MS Access:
  • Load .txt file into MS Access;
  • Folloow the import Wizard, which will show you yur imported file after you respond to how the file is delimited. In your case, you would select, "comma delimited";
  • The file is then displayed. You will have the option to adjust the columns and name them (columns). Also the Wizard will ask if you wanted to add the primary key;
  • Save the file in a table;
  • The End;
Next is to export your table using the MS XL format;
Give the output file a name with the .xls extention;
File is created;
Locate file .xls and upload file into your SQL database;

Just another way of getting what you need.
__________________
Disclaimer: The above comments are solely the opinion of one person and not to be construed as a directive or an incentive to commit fraudulent acts.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Comma Separated values aldwinenriquez SQL Server 2005 3 June 1st, 2007 09:52 PM
comma separated list MunishBhatia SQL Server 2000 11 March 21st, 2007 04:56 PM
Comma Separated Column Value thru T-SQL subhendude SQL Server 2000 2 December 12th, 2006 01:42 PM
comma separated list of attributes rjonk XSLT 3 September 27th, 2006 12:52 PM
Select from Comma Separated Values sasidhar79 SQL Server 2000 2 March 28th, 2005 06:58 PM



All times are GMT -4. The time now is 04:03 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
© 2010 Wiley Publishing, Inc