i'm trying to create a package that will copy data from a file and put it into a new table. so far so good. but should the package fail for some reason, i want it to truncate the newly added data. so, i want it to execute this statement
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'TABLE_NAME') AND type in (N'U')) DELETE FROM TABLE_NAME WHERE date='2015-11-10'
but i keep getting this error: "Error: 0xC002F210 at Delete From MYTABLE, Execute SQL Task: Executing the query "IF EXISTS (SELECT * FROM sys.objects WHERE object_..." failed with the following error: "Invalid column name 'date'.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly."
but MYTABLE does have a column called "date"... i just can't figure out what the problem is, and google hasn't been able to help me.
I believe "date" is a reserved word, try using [date]
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'TABLE_NAME') AND [type] in (N'U')) DELETE FROM TABLE_NAME WHERE [date]='2015-11-10'
SQL Server reserved Words: MSDN
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments