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
 space delimited

Author  Topic 

dexter123
Starting Member

4 Posts

Posted - 2012-03-01 : 17:11:03
I have a space delmited file as below and would like to create a table with two columns.

Time_Stamp=Wed Feb 29 00:01:16 2012
Char_Results=820yytUIT
Time_Stamp=Wed Feb 29 00:02:45 2012
Char_Results=710jutyWD
Time_Stamp=Wed Feb 29 00:07:05 2012
Char_Results=JUH678UJ
Time_Stamp=Wed Feb 29 00:08:25 2012
Char_Results=BM90KLUI
Time_Stamp=Wed Feb 29 00:11:19 2012
Char_Results=YHE43rRT

CREATE TABLE tran_data
( date_time varchar (100), char_data varchar (50))


Giving errors

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-03-01 : 23:05:08
whats the issue you're facing? how are you trying to populate table?

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

Go to Top of Page

dexter123
Starting Member

4 Posts

Posted - 2012-03-02 : 08:07:42
i know i can do this with one column and bulk insert using below, but i need to seperate the text file into two colums one column with date and timme information and the second column with the char_results as in my first post.

---CREATE TABLE trans_data
---(date_time varchar (100))

BULK
INSERT trans_data
FROM 'c:\temp\trans.txt'
WITH
(
DATAFILETYPE = 'char',
FIELDTERMINATOR = '\O',
ROWTERMINATOR = '\n'
)
GO
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-03-02 : 12:14:34
you can use a SSIS package for that. use derived column transformation to spilt column values inside data flow task which does the data transfer

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

Go to Top of Page
   

- Advertisement -