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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 The if statement not work

Author  Topic 

Ali.M.Habib
Yak Posting Veteran

54 Posts

Posted - 2009-01-29 : 08:11:30
when run this code the if statement not work and always give the error
There is already an object named 'Basic_Statistics' in the database.

-------------- Create the basic tble---------------
IF OBJECT_ID ('dbo.Basic_Statistics','U') IS NULL
create table Basic_Statistics
(
BS_ID tinyint identity(1,1),
BS_TableName varchar(100),
BS_ColumnName varchar(100),
BS_Type varchar(100)
)

-------------------- Create secondroy statistics
IF OBJECT_ID ('dbo.Secnd_Statistics','U') IS NULL
create table Secnd_Statistics
(
Sec_BS_ID tinyint identity(1,1),
Sec_Value varbinary(100)

)
how can I fix that please

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-01-29 : 08:18:13
Use same schema for checking as creating!
-------------- Create the basic tble---------------
IF OBJECT_ID ('dbo.Basic_Statistics','U') IS NULL
create table dbo.Basic_Statistics
(
BS_ID tinyint identity(1,1),
BS_TableName varchar(100),
BS_ColumnName varchar(100),
BS_Type varchar(100)
)

-------------------- Create secondroy statistics
IF OBJECT_ID ('dbo.Secnd_Statistics','U') IS NULL
create table dbo.Secnd_Statistics
(
Sec_BS_ID tinyint identity(1,1),
Sec_Value varbinary(100)
)



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page
   

- Advertisement -