Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Text to SQL Columns

Author  Topic 

rcapilli
Starting Member

1 Post

Posted - 2010-02-24 : 12:18:59
Is there a way to take text (from any program, notepad?):

col1 nvarchar(500) Checked
col2 int Checked

and paste/build a column in a table with the info above?

[COLUMN NAME] [TYPE] [ALLOW NULL]
col1 nvarchar(500) Checked
col2 int Checked

Kristen
Test

22859 Posts

Posted - 2010-02-24 : 12:22:25
You have text data with 3 columns, delimited by spaces, and with each row separated by CR / LF, and you want to insert them into a table with three, corresponding, columns?

Then "yes"

BCP will do this (as a batch operation)

Or SQL server provides a tool called SSIS which will get "flat file" data into a table

Or you can have some SQL code that will "split" each row at the CR / LF, and then split each "column" at the space.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-02-24 : 12:36:46
I dont think you can do that without using dynamic sql. B/w is this MS SQL Server? what does checked mean?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-02-25 : 02:05:52
quote:
Originally posted by Kristen

You have text data with 3 columns, delimited by spaces, and with each row separated by CR / LF, and you want to insert them into a table with three, corresponding, columns?

Then "yes"

BCP will do this (as a batch operation)

Or SQL server provides a tool called SSIS which will get "flat file" data into a table

Or you can have some SQL code that will "split" each row at the CR / LF, and then split each "column" at the space.


OP specified that Column informations are available in the text file (not actual data) and a table should be created based on the informations. It is not as easy as you import data. As Visakh said, only way is dynamic SQL

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2010-02-25 : 02:22:15
" a table should be created based on the informations"

I didn't read it that way, But I realised that could be the meaning, which is why I asked for clarification.

But O/P is AWOL ...
Go to Top of Page
   

- Advertisement -