|
|
 |
| 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 .
|
 |
|
|
 |

October 1st, 2009, 09:09 PM
|
|
Authorized User
|
|
Join Date: Dec 2006
Location: Texas, TX, USA.
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|

October 6th, 2009, 09:03 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Location: Tehran, Iran
Posts: 926
Thanks: 0
Thanked 4 Times in 4 Posts
|
|
SELECT REPLACE(Name1 , ',', ' ')
__________________
Always[:)],
Hovik Melkomian.
|

October 7th, 2009, 03:24 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2008
Location: Snohomish, WA, USA
Posts: 1,378
Thanks: 3
Thanked 78 Times in 77 Posts
|
|
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.
|

October 7th, 2009, 03:26 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2008
Location: Snohomish, WA, USA
Posts: 1,378
Thanks: 3
Thanked 78 Times in 77 Posts
|
|
Yes! You did!
Why didn't you READ the answer I gave you yesterday????
SQL Server 2008 Query (comma separated)
|

October 9th, 2009, 02:52 AM
|
|
Friend of Wrox
|
|
Join Date: May 2005
Location: OKC, OK, USA.
Posts: 218
Thanks: 1
Thanked 7 Times in 7 Posts
|
|
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.
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |