![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hi, Does anyone know how to make this simple SQL query using a SSIS Data Flow Destination Task? IF NOT EXISTS (SELECT * FROM Table WHERE Username = @Username) BEGIN INSERT table(Username, Firstname, Lastname) VALUES (@Username, @Firstname, @Lastname) END I have tried both the OLE DB Destination and SQL Server destination. The latter does not even let you specify a SQL query and the OLE DB task does not allow me to specify a SQL statement with parameters. Please help. I am stuck in quicksand and there are very limited resources available out there. Thanks |
#3
| |||
| |||
|
#4
| |||
| |||
|
#5
| |||
| |||
|
|
Allan, Thanks for you answer. I looked over the articles. Since my source is a flat file I assume I would have to read that into a recordset then do a ForEach loop through the rows in that recordset and run a OLE DB Command with my sql statement? |
#6
| |||
| |||
|
|
Allan, I am having a bit of an issue setting up the parameters for the following query: IF NOT EXISTS (SELECT * FROM Table WHERE Username = ?) BEGIN INSERT table(Username, Firstname, Lastname) VALUES (?, ?, ?) END In the ForLoop the variable mapping are User::Username 0, User::Firstname 1, User::LastName 2 In the Execute SQL Task the parameter mappings are: User::Username, Input, VARCHAR, 0 User::Username, Input, VARCHAR, 1 User::Firstname, Input, VARCHAR, 2 User::LastName, Input, VARCHAR, 3 This does not work. I believe its because I use Username twice. If I remove the outer IF NOT EXISTS and only do the INSERT statement and modify the Execute SQL Task to the following: User::Username, Input, VARCHAR, 0 User::Firstname, Input, VARCHAR, 1 User::LastName, Input, VARCHAR, 2 It works fine. Not the fastest solution though, it took a few seconds to do a thousand rows. Please let me know what I am doing wrong. Thanks |
![]() |
| Thread Tools | |
| Display Modes | |
| |