use @DBNAMEYEAR

if not exists (SELECT name 	  FROM 	 sysobjects 	  WHERE  name = N'webExtraWorkRequest' 	  AND 	 type = 'U')
begin 
begin tran createwebExtraWorkRequest
 
CREATE TABLE [dbo].[webExtraWorkRequest](
	[pageNO] [int] IDENTITY(1,1) NOT NULL,
	[perno] [char](@pernoLenght) COLLATE Arabic_CI_AS NULL,
	[BEGINDATE] [char](5) COLLATE Arabic_CI_AS NULL,
	[BEGINTIME] [char](5) COLLATE Arabic_CI_AS NULL,
	[ENDDATE] [char](5) COLLATE Arabic_CI_AS NULL,
	[ENDTIME] [char](5) COLLATE Arabic_CI_AS NULL,
	[requestDate] [char](5) COLLATE Arabic_CI_AS NULL,
	[status] [int] NULL,
	[lastChangeDate] [char](5) COLLATE Arabic_CI_AS NULL,
	[approvedBy] [char](@pernoLenght) COLLATE Arabic_CI_AS NULL,
	[IsTransfer] [bit] NULL,
	[userDescription] [text] COLLATE Arabic_CI_AS NULL,
	[adminDescription] [text] COLLATE Arabic_CI_AS NULL,
	[PersonelsPerno] [text] COLLATE Arabic_CI_AS NULL,
	[PersonelsName] [text] COLLATE Arabic_CI_AS NULL,
) ON [PRIMARY]

if @@ERROR > 0 
  rollback tran createwebExtraWorkRequest	
commit 

end
else
begin
IF NOT EXISTS (SELECT  * FROM syscolumns WHERE  name = 'adminDescription' AND id = object_Id(N'webExtraWorkRequest')) 
ALTER TABLE webExtraWorkRequest ADD adminDescription [text] NULL 

IF NOT EXISTS(SELECT   * FROM syscolumns WHERE     name = 'approvedBy' AND id = object_Id(N'webExtraWorkRequest')) 
begin
ALTER TABLE webExtraWorkRequest ADD [approvedBy] char(@pernoLenght) NULL
end
else
begin
Alter Table webExtraWorkRequest Alter Column approvedBy char(@pernoLenght)  Null
end

IF EXISTS(SELECT   * FROM syscolumns WHERE     name = 'approveBy' AND id = object_Id(N'webExtraWorkRequest')) 
begin
ALTER TABLE webExtraWorkRequest DROP COLUMN approveBy
end

IF NOT EXISTS (SELECT  * FROM syscolumns WHERE  name = 'PersonelsPerno' AND id = object_Id(N'webExtraWorkRequest'))
begin 
ALTER TABLE webExtraWorkRequest ADD PersonelsPerno [text] NULL 
ALTER TABLE webExtraWorkRequest ADD PersonelsName [text] NULL 
end
end

update webExtraWorkRequest set IsTransfer=0 where IsTransfer is NULL
