joe Posted January 16, 2007 Share Posted January 16, 2007 Hi All,I wanted to use the undocumented SP sp_MSForEachTable to selectively delete data from tables. So in short i want to achieve something like this using sp_MSForEachTable.delete from TableName where Date = '2007-01-03'I looked at various queries on the internet using sp_MSForEachTable, but was not able to find out the usage of sp_MSForEachTable with a "Where" clause, so if anybody has the query or links request to post it here.All that I found was to delete all data from all the tables in the db.I tried using the @whereand option like this, but the got an error saying Invalid column: SomeDate. I have this column in all the tables in that database. I did a quick check looping thro all the tables using cursors and that works fine.EXEC sp_MSForEachTable @command1='DELETE FROM ?',@whereand='and SomeDate = "2007-01-15"'Thanks.PJ Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now