SSIS - How to insert into OLE DB destination using SQL command while the source is flat file?

1.3k views Asked by At

I want to know how to insert value in SQL Server database with the flat file source in SSIS using SQL command. I've done inserting it using table view, now i have to insert it using SQL command

1

There are 1 answers

0
El.Hum On

Well you need a good query to set into a Execute SQL Task in SSIS you can get help for queries in the site below ----here is the link ---- well you can parametrize the query in Execute SQl Task of SSIS

BCP

This is one of the options that is mostly widely used. One reason for this is that it has been around for awhile, so DBAs have come quite familiar with this command. This command allows you to both import and export data, but is primarily used for text data formats. In addition, this command is generally run from a Windows command prompt, but could also be called from a stored procedure by using xp_cmdshell or called from a SSIS package.

Here is a simple command for importing data from file C:\ImportData.txt into table dbo.ImportTest.

bcp dbo.ImportTest in 'C:\ImportData.txt' -T -SserverName\instanceName

BULK INSERT

This command is a T-SQL command that allows you to import data directly from within SQL Server by using T-SQL. This command imports data from file C:\ImportData.txt into table dbo.ImportTest.

BULK INSERT dbo.ImportTest FROM 'C:\ImportData.txt' WITH ( FIELDTERMINATOR =',', FIRSTROW = 2 )

Forgot to say that u can write a select query too with the samples in a OLEDB Source Using Sql Command