SQL Server 2008'de bir SQL Server veritabanında bir tablonun olup olmadığını nasıl belirleyebilirim?
SQL Server 2008'de bir SQL Server veritabanında bir tablonun olup olmadığını nasıl belirleyebilirim?
Yanıtlar:
Sysobjects tablosunu,
SELECT * FROM sysobjects WHERE xtype = 'U' AND name = 'yourTableName'
xtype = 'U' bir kullanıcı tablosu
daha sonra bu bir IF EXISTS ifadesidir
IF EXISTS (SELECT * FROM sysobjects ...)
BEGIN
' do your stuff here if it exists
END
İşte onu bulmanın bir yolu daha
IF OBJECT_ID('tablename') IS NULL
PRINT 'Table Does not Exist'
IF EXISTS (SELECT * FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_NAME = 'your table name here')
BEGIN
PRINT 'Table Exists'
END