SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Administration
 Create Table + Bulk Insert
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

andreandre
Starting Member

2 Posts

Posted - 12/16/2012 :  07:01:55  Show Profile  Reply with Quote
Hi guys,

I have a .csv file wich has the following information (exactly like this):



List Name: User
Format Version:1.2.5.0
Date:12/11/2012 12:00:34
Equipment.:L6867000214
IP:172.21.12.62


User,Name,Total,B&W
[1600],[technical],76,76
[6611],[Daise],559,559
[900301],[Richard],0,0



I want to execute a create table and a bulk insert transaction but I don't know how to insert the information of the top lines of the .csv file like "Equipment.:L6867000214" and "IP:172.21.12.62". I need to create a collumn called "Equipment", other collumn called "IP" and insert this information (repeat "L6867000214" and "172.21.12.62" in all records bulk inserted). The result must be like this:


IP,Equipment.,User,Name,Total,B&W, Color
172.21.12.62,L6867000214,[1600],[technical],76,76
172.21.12.62,L6867000214,[6611],[Daise],559,559
172.21.12.62,L6867000214,[900301],[Richard],0,0


I have no ideia how to do that. Could anyone here help me out on this issue?

Thanks a lot!

visakh16
Very Important crosS Applying yaK Herder

India
52249 Posts

Posted - 12/19/2012 :  00:45:35  Show Profile  Reply with Quote
sounds like you need to use SSIS for first getting header information onto variables and then use them to repeat for each of detail rows

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

Go to Top of Page

andreandre
Starting Member

2 Posts

Posted - 12/23/2012 :  22:37:44  Show Profile  Reply with Quote
Hi visakh16,

Thank you for your response.

SSIS would solve this problem? How do I use it?

Thanks!
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52249 Posts

Posted - 12/24/2012 :  15:29:41  Show Profile  Reply with Quote
you need to use 2 separate data flow tasks one for getting header info and storing them in variables. then second data flow task to get actual data part and use derived column to include header as well.

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

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000