Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
Just_Jeff
Starting Member
7 Posts |
Posted - 2011-11-08 : 15:56:40
|
| I've inherited a database that has 2 sets of nearly identical tables. The primary set is assigned to the 'dbo' schema. There is a second set of tables that are almost identical to the primary set but they are assigned to the 'history' schema.For instance I have 2 tables named tblCompany. dbo.tblCompany history.tblCompanyHow do I identify the correct table to drop with a statement like the following:IF EXISTS(SELECT * FROM sys.objects WHERE type='U' AND name='tblCompany') DROP TABLE history.tblCompanyGOThe select statement returns 2 records, one from each schema. I want to check for the existence of a table from a specific schema. How do I do this?Thanks,Jeff |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
Just_Jeff
Starting Member
7 Posts |
Posted - 2011-11-08 : 16:21:53
|
| Thanks. I think I found another way to do it as well.SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[history].[tblCompany]') AND type in (N'U')Jeff |
 |
|
|
|
|
|