tags:

views:

147

answers:

4

i want to insert csv file with special character how can csv file to sql server database with special character

+1  A: 

Sql bulk insert

Alex Reitbort
alter procedure test_123asBULKINSERT ExcelToDBFROM 'D:\EtilizedataSaba211009.csv'WITH (CODEPAGE = 'RAW', FIELDTERMINATOR = ',',ROWTERMINATOR = '\n', ROWS_PER_BATCH = 10000, TABLOCK)GOthis procedure isnot working
chaitali
not working how?
Alex Reitbort
A: 

You can use the BULK INSERT T-SQL command (it also has a command line version):

http://msdn.microsoft.com/de-de/library/ms188365.aspx

davek
A: 

Sql Bulk insert

priyanka.sarkar
A: 

Besides SQL BULK insert, you could also check out the SQL Server Integration Services, if you have to do this just once.

In SQL Server Management Studio, go to the Object Explorer, find your database, right click on it, and then choose "Tasks > Import Data". This brings up the SSIS wizard, which allows you to pick a source (your CSV file), a target (your SQL Server database+table), and it supports picking just certain fields, renaming them and much more.

For "do it once" operations, this is quite a nice and useful wizard.

marc_s
However, if you have data in columns that might be larger than 50 characters, you need to adjust the column sizes. I've never yet imported a file this way where I didn't have to do that for at least one column.
HLGEM
Hmm.... I just inserted a large number of Excel sheets with columns of 255 chars of width - no manual intervention necessary.... (SSIS 2008)
marc_s