June 25, 2010 at 9:50 am
Since 'cross' is a reserved keyword, I get the following error message:
Msg 156, Level 15, State 1, Line 1
Incorrect syntax near the keyword 'CROSS'.
when I execute EXEC sp_MSforeachdb 'USE ?; EXEC sp_spaceused'
I need to use sp_MSforeachdb to execute a variety of DBA scripts on a lot of servers today as I am preparing reports for a pricey analyst.
TIA!
[font="Courier New"]ZenDada[/font]
June 25, 2010 at 9:52 am
EXEC sp_MSforeachdb 'USE [?]; EXEC sp_spaceused'
June 25, 2010 at 9:59 am
Thanks! That did the trick!
[font="Courier New"]ZenDada[/font]
July 8, 2010 at 7:42 am
Since this has happened, you'll need to remember to encapsulate the DB name with [] every time it's used. If you use other 'dynamic scripts', make sure you check that they aren't failing on the same issue. It's would be a good practice to always encapsulate your [DB Name].[owner].[Table].[Column] whenever they are referenced if you can't control changes.
/* Anything is possible but is it worth it? */
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply