February 8, 2008 at 10:09 am
I would like to run an update statement within the sp_msforeachtable stored procedure, but I don't know the exact syntax. I think it should be something like...
EXEC sp_MSforeachtable
SET = ‘X’
SET = ‘X’
COMMIT;
But am unsure about if it would update what I want it to. Any help is appreciated. I am just trying to set two whole columns = 'X' so no need for a where.
-Kyle
February 8, 2008 at 1:18 pm
Kyle Schlapkohl (2/8/2008)
I would like to run an update statement within the sp_msforeachtable stored procedure, but I don't know the exact syntax. I think it should be something like...EXEC sp_MSforeachtable
SET = ‘X’
SET = ‘X’
COMMIT;
But am unsure about if it would update what I want it to. Any help is appreciated. I am just trying to set two whole columns = 'X' so no need for a where.
-Kyle
EXEC sp_MSForEachTable 'UPDATE ? SET COLUMN = VALUE'
Personally, I'd advise against using foreachtable, unless you really do want to hit every single table in this database. I'd use a cursor or a loop and filter your objects appropriately.
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply