I have a need to iterate over all of the tables in my database. I am doing so with thsi query:
SELECT so.name, so.*
FROM sysobjects so
WHERE so.xtype = 'U'
This works fine for all of the tables in the 'dbo' schema, but it doesn't work for any other schemas. I want the output to be like this:
Users.Address Users.TelephoneNumbers dbo.GlobalSettings dbo.Configuration
Instead I get this:
Address TelephoneNumber GlobalSettings Configuration
When I try to construct dynamic SQL queries, it fails because it can't find the Address and TelephoneNumber tables because their schema is not the default 'dbo'.
Any ideas?