SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Load CSV file into temptable


Load CSV file into temptable

Author
Message
SQListic
SQListic
SSCommitted
SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)

Group: General Forum Members
Points: 1618 Visits: 1115
Hi Experts,

can some one share script which loads data into temptable from csv file.?
bitbucket-25253
bitbucket-25253
SSCoach
SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)

Group: General Forum Members
Points: 16187 Visits: 25280
You can learn how by going to this link.

http://msdn.microsoft.com/en-us/library/ms141209(v=sql.100).aspx

If everything seems to be going well, you have obviously overlooked something.

Ron

Please help us, help you -before posting a question please read

Before posting a performance problem please read
SQListic
SQListic
SSCommitted
SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)

Group: General Forum Members
Points: 1618 Visits: 1115
Thanks for the reply ron,

I am expecting a script, not thru GUI

Thanks again Smile
bitbucket-25253
bitbucket-25253
SSCoach
SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)

Group: General Forum Members
Points: 16187 Visits: 25280
Sqlism (10/15/2012)
Thanks for the reply ron,

I am expecting a script, not thru GUI

Thanks again Smile


In the previous link note the following:

You can also decide whether to save the package to SQL Server or to the file system. If you select to save the package, you must also specify a package protection level. For more information about package protection levels, see Setting the Protection Level of Packages.

After the SQL Server Import and Export Wizard has created the package and copied the data, you can use the SSIS Designer to open and change the saved package.



If everything seems to be going well, you have obviously overlooked something.

Ron

Please help us, help you -before posting a question please read

Before posting a performance problem please read
demonfox
demonfox
SSCrazy
SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)

Group: General Forum Members
Points: 2193 Visits: 1192
Let me know if this helps..

CSV FILE : Test.csv
a,b
1,A
2,B
3,C


Then in the SSMS :

create table #test(a int,b varchar)

BULK INSERT #test1
FROM 'C:\Test.csv'
WITH
(
FIELDTERMINATOR =',',
ROWTERMINATOR =' ',
FIRSTROW = 2
)


Edit :ROWTERMINATOR = '\ n'

This is one way to load from csv file to a table ...
FIRSTROW is a check to filter out loading headers..

~ demonfox
___________________________________________________________________
Wondering what I would do next , when I am done with this one Ermm
SQListic
SQListic
SSCommitted
SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)

Group: General Forum Members
Points: 1618 Visits: 1115
Thanks for the script demonfox!

It works for me.

is there anyway, we can load data without declaring coulmn names and data types(data type is not the issue for me)

My csv file has first row as column names
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search