Delete Script in SSIS
Hi
i want to run a delete query before i execute a dataflow task..
My query is very simple: delete tablename where column name = ''
whats the best way to do this?
September 24th, 2011 7:03am
You can do this with Execute SQL Task or OLEDB command...
The OLE DB Command runs insert, update or delete statement for each row, while the Execute Sql Task does a Bulk Insert in this instance. That means every single row that goes through your package would have an insert statement
run when it gets to an OLE DB Command.
Mark as answer if it serves your purpose..
Regards,
Indraneel A
Free Windows Admin Tool Kit Click here and download it now
September 24th, 2011 7:08am
i was trying to run this inside execute sql task,but i dont want the result set stuff...can you give me an example..
September 24th, 2011 7:16am
Firstly why would you get an result set when you run a Delete query??? Check the below screen shot. If you are looking for something else.... lemme know.
Mark as answer if it served your purpose....
Regards,
Indraneel A
Free Windows Admin Tool Kit Click here and download it now
September 24th, 2011 7:29am
Couldn't see your image...but this is what i am doing inside execute sql task:
SELECT NameStyle, Title, FirstName
FROM Person.Contact
WHERE (ContactID = @user::ID)
and passing the value of the where condition through an variable.. and i am getting this error...
[Execute SQL Task] Error: Executing the query "SELECT NameStyle, Title, FirstName
FROM ..." failed with the following error: "Parameter name is unrecognized.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.
where in the connection is proper...
September 24th, 2011 7:33am
Firstly why would you get an result set when you run a Delete query??? Check the below screen shot. If you are looking for something else.... lemme know.
Mark as answer if it served your purpose....
Regards,
Indraneel A
Free Windows Admin Tool Kit Click here and download it now
September 24th, 2011 7:33am
this is what i was doing,but how shd i pass an value from a variable in place of 'INDRANEEL' ?
September 24th, 2011 7:53am
Check this post...that will give you complete info you wanted.
Link http://www.sqlis.com/post/The-Execute-SQL-Task.aspx
Regards,
Indraneel A
Free Windows Admin Tool Kit Click here and download it now
September 24th, 2011 8:13am
Hey even i got the some error message while trying your question. But now its solved.
Query should be DELETE FROM dbo.[OLE DB Destination] WHERE ([Names] = ?)
Now in the Parameter Mapping TAB Set the Parameter Name to " 0 ". Its default value is " New Parameter Name "
Check the below Screen shot....
Please mark as answer... i think its your problem is resolved. In case of any queries further let me know.
Regards,
Indraneel
September 24th, 2011 12:03pm
Hi
i tried the same
query: use TEST
delete dbo. Person WHERE (Modified Date = ?)
and my variable is called Modified Date with the datatype as datetime and value as 9/30/2009
parameter mapping is set to DBDATE
and all the other settings as you mentioned.
It executes perfectly for ID,and other columns but for date field its not working ad i need to get this working for date field..
Please,look in to this..
this is how my data looks:
1 Sam
Roberts
2009-09-30 00:00:00.000
2 Jeff
Mason 2009-09-30 00:00:00.000
Free Windows Admin Tool Kit Click here and download it now
September 24th, 2011 2:59pm
Did u try deleting it directly from SSMS ???...check whether thats possible or not... If there is some problem there u will have to contact ur DBA
I have done an POC in my system....its deleting the records
What are the values stored in your ID variable???
Regards,
Indraneel A
September 24th, 2011 3:04pm
sorry as i said bove its working for other fields but not for date...and my date has a datatype of datetime..
Free Windows Admin Tool Kit Click here and download it now
September 24th, 2011 3:11pm
ohh god so many changes in the question....
SQL Query : Delete from studentjoinings where exists ( select names,DOJ from
studentjoinings where convert(datetime, convert(char, DOJ, 106)) = '2011-09-19')
Delete from studentjoinings where exists ( select names,DOJ from
studentjoinings where convert(datetime, convert(char, DOJ, 106)) = ? )
This will delete irrespective of the time. It checks whether the data is matched or not.
Go a ahead an try your luck. May be next time when you post ur question be specific.
Mark as answer if it serves your purpose.
Regards,
Indraneel A
September 24th, 2011 9:41pm