use @DBNAME

if not exists (SELECT name 	  FROM 	 sysobjects 	  WHERE  name = N'PatternDetail'  AND 	 type = 'U')
begin 
begin tran createPatternDetail
 
CREATE TABLE [dbo].[PatternDetail](
	[PatternID] [int]  NOT NULL,
	[pageKind] [int] NULL,
	[Code] [int] NULL,
	[statusCode] [int] NULL,
) ON [PRIMARY]

if @@ERROR > 0 
  rollback tran createPatternDetail
commit 

end
