• 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/