SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Undocumented Extended and Stored Procedures


Undocumented Extended and Stored Procedures

Author
Message
Charles Kincaid
Charles Kincaid
Hall of Fame
Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)

Group: General Forum Members
Points: 3191 Visits: 2384
You are going to just love this one! Try it like this:
exec dbo.sp_msforeachtable 'select * from ?'



Note the lack of brackets. Go figure.

ATBCharles Kincaid
timothyawiseman
timothyawiseman
SSCrazy
SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)

Group: General Forum Members
Points: 2300 Visits: 920
m.ciesiensky (1/6/2010)
Timothy,
when attempting to run sp_msforeachtable in each of the variations below, I get these errors. I have tried running from both the master and CBL databases, with all same results.
Any Ideas?

exec dbo.sp_msforeachtable 'select * from CBL.dbo.[?]'


Msg 208, Level 16, State 1, Line 1
Invalid object name 'CBL.dbo.[dbo].[ae_amap]'.



Any help from anyone will be much appreciated.


The ? in sp_msforeachtable includes the schema already and is already quoted. In other words, remove the dbo. and the brackets and it should work. Something like:

exec sp_msforeachtable 'select * from ?'



if you are doing it inside CBL or

exec sp_msforeachtable 'select * from CBL.?'



if you want or need to fully qualify it.

---
Timothy A Wiseman
SQL Blog: http://timothyawiseman.wordpress.com/
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search