USE @DBNAME

if not exists (SELECT name 	  FROM 	 sysobjects 	  WHERE  name = N'WebSection' 	  AND 	 type = 'U')
begin 
begin tran createWebSection
CREATE TABLE [dbo].[webSection](
	[id] [int] IDENTITY(1,1) NOT NULL PRIMARY KEY,
	[sectionCode] [char](30) COLLATE Arabic_CI_AS  NULL,
	[sectionName] [nvarchar](500) COLLATE Arabic_CI_AS NULL,
	[perno] [char](@pernoLenght) COLLATE Arabic_CI_AS NULL,
	[MorApproveCode] [int] NULL,
	[MamApproveCode] [int] NULL,
	[IOApproveCode] [int] NULL,
	[ExtraWorkApproveCode] [int] NULL,
	[adminPermission] [char] (100) NULL,
	[isManager] [bit] NULL,

) ON [PRIMARY]


if @@ERROR > 0 
  rollback tran createWebSetting    
commit 
end



IF EXISTS(SELECT   * FROM syscolumns WHERE     name = 'adminPermission' AND id = object_Id(N'webSection')) 
begin

update webSection set [adminPermission] = '0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000' where adminPermission is NULL

end
 





