|
|
 |
| 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 p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.
|
 |

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: 922
Thanks: 0
Thanked 1 Time in 1 Post
|
|
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,323
Thanks: 3
Thanked 70 Times in 69 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,323
Thanks: 3
Thanked 70 Times in 69 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: 211
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
|
|
|
|
 |