October 15, 2012 at 5:57 pm
Hi Experts,
can some one share script which loads data into temptable from csv file.?
October 15, 2012 at 6:24 pm
You can learn how by going to this link.
http://msdn.microsoft.com/en-us/library/ms141209(v=sql.100).aspx
October 15, 2012 at 6:43 pm
Thanks for the reply ron,
I am expecting a script, not thru GUI
Thanks again 🙂
October 15, 2012 at 7:05 pm
Sqlism (10/15/2012)
Thanks for the reply ron,I am expecting a script, not thru GUI
Thanks again 🙂
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.
October 15, 2012 at 11:24 pm
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:
October 16, 2012 at 10:41 am
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
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply