24 July, 2009
0 Comments
1 category
To check if a table exists in a SQL Server 2008 database, use the following T-SQL code:
Use the system view sys.objects and not the old sql server 2000 system table sysobjects
if not exists (select 1 from sys.objects o where o.name =’TableName’ and o.type =’U’)
begin
create tabledbo.TableName (
Id int identity(1,1) not nullprimary key,
Barcode varchar(35) not null
) end go
Tags: SQL Server
Category: Uncategorized