if object_id('specialrep') is null create table specialrep (sqlind int identity not null primary key ,repcode int null  ,repcode1 smallint null  ,node smallint null ,choosed bit null ,Name nvarchar(30) null ,rep varbinary(max) null)
if object_id('bijak') is null create table bijak ([sqlind] [int] IDENTITY(1,1) NOT NULL,[code] [int] NULL,[tarikh] [int] NULL,[Sal] [smallint] NULL,[Mah] [smallint] NULL,[Roz] [smallint] NULL,[fshom] [float] NULL,[shom] [float] NULL,[barbarname] [nvarchar](30) NULL,[barbaradr] [nvarchar](255) ,[ted] [int] NULL,[sharh] [nvarchar](255) NULL,[noh] [nvarchar](255) NULL,[gir] [nvarchar](30) NULL,[giradr] [nvarchar](255) NULL,[girtel] [nvarchar](30) NULL,[fer] [nvarchar](30) NULL,[hamel] [nvarchar](30) NULL,[pish] [bit] NULL,[pishmab] [float] NULL,[pishname] [nvarchar](30) NULL,[barshom] [nvarchar](10) NULL,[barroz] [smallint] NULL,[barmah] [smallint] NULL,[barsal] [smallint] NULL,[bartarikh] [int] NULL,[barsaat] [nvarchar](10) NULL,[baradr] [nvarchar](255) ,[barted] [smallint] NULL,[bartakhmahal] [nvarchar](100) ,[bartakhtel] [nvarchar](30) ,[barsh1] [nvarchar](255) NULL,[barsh2] [nvarchar](255) NULL)
if columnproperty(object_id('specialrep'),'selected','columnid') is null alter table specialrep add selected nvarchar(5) null
if columnproperty(object_id('specialrep'),'mst','columnid') is null alter table specialrep add mst bit null
if columnproperty(object_id('special1'),'kcode','columnid') is null alter table special1 add kcode int null
if columnproperty(object_id('special1'),'gkcode2','columnid')  is null alter table special1 add gkcode2 float null
if columnproperty(object_id('special1'),'gh2','columnid')  is null alter table special1 add gh2 float null
if columnproperty(object_id('special1'),'gindex','columnid')  is null alter table special1 add gindex bigint null
if object_id('daftel') is null create table daftel(sqlind int identity not null primary key,tcode int null ,name nvarchar(30) null ,tel nvarchar(60) null ,mob nvarchar(60) null ,fax nvarchar(60) null ,adr nvarchar(60) null ,adr2 nvarchar(60) null ,adr3 nvarchar(60) null ,sh ntext null ,titr nvarchar(30) null ,contact nvarchar(60) null ,email nvarchar(50) null ,ucode float null )
if object_id('history') is null create table history(sqlind int identity not null primary key,tarikh nvarchar(20),typ smallint ,act smallint ,conrec smallint null ,rec bigint null ,sh nvarchar(150) null ,shold nvarchar(100) null ,shnew nvarchar(100) null ,node smallint null ,code bigint null )
if object_id('khorsh') is null create table khorsh(sqlind int identity not null primary key,type nvarchar(10) null ,sh nvarchar(50) null )
if columnproperty(object_id('khorsh'),'webup','columnid')  is null alter table khorsh add webup bit null
if columnproperty(object_id('khorsh'),'webup1','columnid')  is null alter table khorsh add webup1 bit null
if object_id('khorsh1') is null create table khorsh1(sqlind int identity not null primary key,gindex bigint null,sqlind1 int null,sh nvarchar(255) null )
if columnproperty(object_id('khorsh1'),'webup','columnid')  is null alter table khorsh1 add webup bit null
if columnproperty(object_id('khorsh1'),'webup1','columnid')  is null alter table khorsh1 add webup1 bit null
if columnproperty(object_id('vrfil'),'ttype8','columnid')  is null alter table vrfil add ttype8 bit null
if columnproperty(object_id('khfil'),'ttype8','columnid')  is null alter table khfil add ttype8 bit null
if object_id('kala1') is null create table kala1(sqlind int identity not null primary key,kcode int null ,kcode1 int null ,ucode nvarchar(30) null ,sh nvarchar(30) null )
if columnproperty(object_id('kala1'),'webup','columnid')  is null alter table kala1 add webup bit null
if columnproperty(object_id('kala1'),'webup1','columnid')  is null alter table kala1 add webup1 bit null
if object_id('kalaphor') is null create table kalaphor(sqlind int identity not null primary key,kcode int null ,phor float null ,sath smallint null )
if columnproperty(object_id('kalaphor'),'webup','columnid')  is null alter table kalaphor add webup bit null
if columnproperty(object_id('kalaphor'),'webup1','columnid')  is null alter table kalaphor add webup1 bit null
if object_id('anbar2') is null create table anbar2(sqlind int identity not null primary key,kcode int null ,anbcode smallint null ,ted2_1 float null ,ted_1 float null ,ted2_2 float null ,ted_2 float null ,ted2_3 float null ,ted_3 float null )
if columnproperty(object_id('anbar2'),'webup','columnid')  is null alter table anbar2 add webup bit null
if columnproperty(object_id('anbar2'),'webup1','columnid')  is null alter table anbar2 add webup1 bit null
if object_id('holiday') is null create table holiday(sqlind int identity not null primary key,tarikh nvarchar(10) null ,nday smallint null ,name nvarchar(25) null )
if columnproperty(object_id('holiday'),'webup','columnid')  is null alter table holiday add webup bit null
if columnproperty(object_id('holiday'),'webup1','columnid')  is null alter table holiday add webup1 bit null
if columnproperty(object_id('holiday'),'roz','columnid')  is null alter table holiday add roz smallint null
if columnproperty(object_id('holiday'),'mah','columnid')  is null alter table holiday add mah smallint null
if columnproperty(object_id('holiday'),'sal','columnid')  is null alter table holiday add sal smallint null
if columnproperty(object_id('holiday'),'ndayname','columnid')  is null alter table holiday add ndayname nvarchar(10) null
if columnproperty(object_id('packing'),'khortar','columnid')  is null alter table packing add khortar nvarchar(10)
if columnproperty(object_id('packing'),'havtar','columnid')  is null alter table packing add havtar nvarchar(10)
alter table packing alter column vorodrgindex float
alter table packing alter column khorojrgindex bigint
alter table packing alter column havalehrgindex bigint
if columnproperty(object_id('roznameh'),'printed','columnid')  is null alter table roznameh add printed bit null
if columnproperty(object_id('roznameh'),'lastok','columnid')  is null alter table roznameh add lastok bit null
if columnproperty(object_id('profile'),'khpr1','columnid')  is null alter table profile add khpr1 smallint null
if columnproperty(object_id('profile'),'rizroz','columnid')  is null alter table profile add rizroz bit null
if columnproperty(object_id('profile'),'rozsal1','columnid')  is null alter table profile add rozsal1 smallint null
if columnproperty(object_id('profile'),'rozmah1','columnid')  is null alter table profile add rozmah1 smallint null
if columnproperty(object_id('profile'),'rozroz1','columnid')  is null alter table profile add rozroz1 smallint null
if columnproperty(object_id('profile'),'rozsal2','columnid')  is null alter table profile add rozsal2 smallint null
if columnproperty(object_id('profile'),'rozmah2','columnid')  is null alter table profile add rozmah2 smallint null
if columnproperty(object_id('profile'),'rozroz2','columnid')  is null alter table profile add rozroz2 smallint null
if columnproperty(object_id('profile'),'kghr1','columnid')  is null alter table profile add kghr1 float null
if columnproperty(object_id('profile'),'kghr2','columnid')  is null alter table profile add kghr2 float null
if columnproperty(object_id('profile'),'crm','columnid')  is null alter table profile add crm bit null
if columnproperty(object_id('repcon'),'srt3','columnid')  is null alter table repcon add srt3 smallint null
if columnproperty(object_id('repcon'),'srt4','columnid')  is null alter table repcon add srt4 smallint null
if columnproperty(object_id('repcon'),'srt1bl','columnid')  is null alter table repcon add srt1bl bit null
if columnproperty(object_id('repcon'),'srt2bl','columnid')  is null alter table repcon add srt2bl bit null
if columnproperty(object_id('repcon'),'srt3bl','columnid')  is null alter table repcon add srt3bl bit null
if columnproperty(object_id('repcon'),'srt4bl','columnid')  is null alter table repcon add srt4bl bit null
if columnproperty(object_id('repcon'),'print1','columnid')  is null alter table repcon add print1 nvarchar(100) null
if columnproperty(object_id('repcon'),'print2','columnid')  is null alter table repcon add print2 nvarchar(100) null
if columnproperty(object_id('repcon'),'print3','columnid')  is null alter table repcon add print3 nvarchar(100) null
if columnproperty(object_id('bankn'),'typ','columnid') is null alter table bankn add typ bit null
if columnproperty(object_id('dcheck'),'repno','columnid')  is null alter table dcheck add repno smallint null
if columnproperty(object_id('picture'),'f1','columnid')  is null alter table picture add f1 nvarchar(50) null
if columnproperty(object_id('picture'),'frec','columnid')  is null alter table picture add frec smallint null
if columnproperty(object_id('picture'),'f2','columnid')  is null alter table picture add f2 nvarchar(50) null
if columnproperty(object_id('picture'),'f3','columnid')  is null alter table picture add f3 nvarchar(50) null
if columnproperty(object_id('picture'),'f4','columnid')  is null alter table picture add f4 nvarchar(50) null
if columnproperty(object_id('picture'),'f5','columnid')  is null alter table picture add f5 nvarchar(50) null
if columnproperty(object_id('picture'),'f6','columnid')  is null alter table picture add f6 nvarchar(50) null
if columnproperty(object_id('picture'),'f7','columnid')  is null alter table picture add f7 nvarchar(50) null
if columnproperty(object_id('picture'),'f8','columnid')  is null alter table picture add f8 nvarchar(50) null
if columnproperty(object_id('picture'),'f9','columnid')  is null alter table picture add f9 nvarchar(50) null
if columnproperty(object_id('picture'),'f10','columnid')  is null alter table picture add f10 nvarchar(50) null
if columnproperty(object_id('picture'),'f11','columnid')  is null alter table picture add f11 nvarchar(50) null
if columnproperty(object_id('picture'),'f12','columnid')  is null alter table picture add f12 nvarchar(50) null
if object_id('tasvor') is null create table tasvor(sqlind int identity not null primary key,code int null ,type smallint null ,tasvor varbinary(max) null ) 
if columnproperty(object_id('tasvor'),'webup','columnid')  is null alter table tasvor add webup bit null
if columnproperty(object_id('tasvor'),'webup1','columnid')  is null alter table tasvor add webup1 bit null
if object_id('log1') is null create table log1(sqlind int identity not null primary key,Datetime nvarchar(20) null ,Type smallint null ,Stationno smallint null ,Userno smallint null ,Sh nvarchar(255) null )
if object_id('sefbill') is not null drop TABLE sefbill
if columnproperty(object_id('taraftel'),'sefup','columnid')  is null alter table taraftel add sefup bit 
if columnproperty(object_id('taraftel'),'sh','columnid')  is null alter table taraftel add sh nvarchar(50) null
if columnproperty(object_id('fartype'),'sefup','columnid')  is null alter table fartype add sefup bit null 
if columnproperty(object_id('kalaghroh'),'sefup','columnid')  is null alter table kalaghroh add sefup bit null
if columnproperty(object_id('kala'),'ucode2','columnid')  is null alter table kala add ucode2 nvarchar(30) null
if columnproperty(object_id('kala'),'titr1','columnid')  is null alter table kala add titr1 nvarchar(50) null
update kala set titr1=titr where titr1 is null
if columnproperty(object_id('kala'),'takhdark2','columnid')  is null alter table kala add takhdark2 float null
if columnproperty(object_id('kala'),'takhdark3','columnid')  is null alter table kala add takhdark3 float null
if columnproperty(object_id('kala'),'takhdark4','columnid')  is null alter table kala add takhdark4 float null
if columnproperty(object_id('kala'),'takhdark5','columnid')  is null alter table kala add takhdark5 float null
if columnproperty(object_id('kala'),'takhdark6','columnid')  is null alter table kala add takhdark6 float null
if columnproperty(object_id('kala'),'vahed2','columnid')  is null alter table kala add vahed2 nvarchar(25) null
if columnproperty(object_id('kala'),'vazn','columnid')  is null alter table kala add vazn float null
if columnproperty(object_id('kala'),'sefok','columnid')  is null alter table kala add sefok bit null
if columnproperty(object_id('kala'),'serok','columnid')  is null alter table kala add serok bit null
if columnproperty(object_id('kala'),'sefup','columnid')  is null alter table kala add sefup bit null
if columnproperty(object_id('kala'),'nodechecked','columnid')  is null alter table kala add nodechecked integer null
if columnproperty(object_id('kala'),'bunch','columnid')  is null alter table kala add bunch smallint null
if columnproperty(object_id('kala'),'sefmojodi','columnid')  is null begin alter table kala add sefmojodi float null update conf set intg16=0 end
if columnproperty(object_id('kala'),'tozcode','columnid')  is null alter table kala add tozcode int null
update kala set tozcode=0 where tozcode is null
if columnproperty(object_id('kala'),'arz','columnid')  is null alter table kala add arz smallint null
if columnproperty(object_id('kala'),'lep','columnid')  is null alter table kala add lep nvarchar(10) null
if columnproperty(object_id('kala'),'loc','columnid')  is null alter table kala add loc nvarchar(10) null
if columnproperty(object_id('kala'),'arzzarib','columnid')  is null alter table kala add arzzarib float null
update kala set arzzarib=1 where arzzarib is null
if columnproperty(object_id('kalasa'),'takhdark2','columnid')  is null alter table kalasa add takhdark2 float null
if columnproperty(object_id('kalasa'),'takhdark3','columnid')  is null alter table kalasa add takhdark3 float null
if columnproperty(object_id('kalasa'),'takhdark4','columnid')  is null alter table kalasa add takhdark4 float null
if columnproperty(object_id('kalasa'),'takhdark5','columnid')  is null alter table kalasa add takhdark5 float null
if columnproperty(object_id('kalasa'),'takhdark6','columnid')  is null alter table kalasa add takhdark6 float null
if columnproperty(object_id('kalasa'),'vahed','columnid')  is null alter table kalasa add vahed nvarchar(25) null
if columnproperty(object_id('kalasa'),'ghr','columnid')  is null alter table kalasa add ghr float null
if columnproperty(object_id('vorod'),'printed','columnid')  is null alter table vorod add printed bit null
if columnproperty(object_id('vorod'),'lastok','columnid')  is null alter table vorod add lastok bit null
if columnproperty(object_id('vorodr'),'kcode1','columnid')  is null alter table vorodr add kcode1 integer
if columnproperty(object_id('khorojr'),'kcode1','columnid')  is null alter table khorojr add kcode1 integer
if columnproperty(object_id('havalehr'),'kcode1','columnid')  is null alter table havalehr add kcode1 integer
if columnproperty(object_id('khoroj'),'printed','columnid')  is null alter table khoroj add printed bit null
if columnproperty(object_id('khoroj'),'lastok','columnid')  is null alter table khoroj add lastok bit null
if columnproperty(object_id('khoroj'),'returned','columnid')  is null alter table khoroj add returned float null
update khoroj set returned=0 where returned is null
if columnproperty(object_id('khoroj'),'sefstr','columnid')  is null alter table khoroj add sefstr nvarchar(10) null
if object_id('kala9') is null create table kala9(sqlind int identity not null primary key,name nvarchar(100) null )
if columnproperty(object_id('kala9'),'webup','columnid')  is null alter table kala9 add webup bit null
if columnproperty(object_id('kala9'),'webup1','columnid')  is null alter table kala9 add webup1 bit null
if object_id('kala10') is null create table kala10(sqlind int identity not null primary key,kcode int null ,kcode1 int null ,anbcode int null ,ted float null ,ted2 float null ,Sh nvarchar(50) null )
if columnproperty(object_id('autocp'),'chghr','columnid')  is null alter table autocp add chghr bit null
if columnproperty(object_id('autocp'),'ghr1','columnid')  is null alter table autocp add ghr1 float null
if columnproperty(object_id('autocp'),'ghr2','columnid')  is null alter table autocp add ghr2 float null
if columnproperty(object_id('autocp'),'p1','columnid')  is null alter table autocp add p1 bit null 
if columnproperty(object_id('autocp'),'p2','columnid')  is null alter table autocp add p2 bit null
if columnproperty(object_id('autocp'),'p3','columnid')  is null alter table autocp add p3 bit null
if columnproperty(object_id('autocp'),'p4','columnid')  is null alter table autocp add p4 bit null
if columnproperty(object_id('autocp'),'p5','columnid')  is null alter table autocp add p5 bit null
if columnproperty(object_id('autocp'),'p6','columnid')  is null alter table autocp add p6 bit null
if columnproperty(object_id('autocp'),'perb1','columnid')  is null alter table autocp add perb1 float null
if columnproperty(object_id('serial1'),'gindex','columnid')  is null alter table serial1 add gindex bigint null
if columnproperty(object_id('serial1'),'typ','columnid')  is null alter table serial1 add typ smallint null
if columnproperty(object_id('serial1'),'tarikh','columnid')  is null alter table serial1 add tarikh integer null
if columnproperty(object_id('stolid'),'tolidcode','columnid')  is null alter table stolid add tolidcode int
if columnproperty(object_id('sandog'),'sod','columnid')  is null alter table sandog add sod float null
if columnproperty(object_id('sandog'),'tcode','columnid')  is null alter table sandog add tcode integer null
if columnproperty(object_id('sandog'),'kcode','columnid')  is null alter table sandog add kcode integer null
if columnproperty(object_id('sandog'),'ojrat','columnid')  is null alter table sandog add ojrat float null
if columnproperty(object_id('sandog'),'kgh','columnid')  is null alter table sandog add kgh float null
if columnproperty(object_id('sandog'),'sod1','columnid')  is null alter table sandog add sod1 float null
if columnproperty(object_id('sandog'),'nkcode','columnid')  is null alter table sandog add nkcode integer null
if columnproperty(object_id('sandog'),'tashkildate','columnid')  is null alter table sandog add tashkildate integer null
if columnproperty(object_id('conf'),'backcolor','columnid')  is null alter table conf add backcolor nvarchar(20) null
if columnproperty(object_id('conf'),'buttoncolor','columnid')  is null alter table conf add buttoncolor nvarchar(20) null
if columnproperty(object_id('conf'),'g1fontname','columnid')  is null alter table conf add g1fontname nvarchar(50) null
if columnproperty(object_id('conf'),'g1fontsize','columnid')  is null alter table conf add g1fontsize smallint null
if columnproperty(object_id('conf'),'g1fontstyle','columnid')  is null alter table conf add g1fontstyle nvarchar(9) null
if columnproperty(object_id('conf'),'g1fontcolor','columnid')  is null alter table conf add g1fontcolor nvarchar(20) null
if columnproperty(object_id('conf'),'sefhes','columnid')  is null alter table conf add sefhes int null
if columnproperty(object_id('conf'),'sefuser','columnid')  is null alter table conf add sefuser int null
if columnproperty(object_id('conf'),'sefpass','columnid')  is null alter table conf add sefpass varbinary(128) null
if columnproperty(object_id('conf'),'newcol4','columnid')  is null alter table conf add newcol4 nvarchar(10) null
if columnproperty(object_id('conf'),'copmint','columnid')  is null alter table conf add copmint nvarchar(30) null
if columnproperty(object_id('conf'),'mal1','columnid')  is null alter table conf add mal1 float null
if columnproperty(object_id('conf'),'mal2','columnid')  is null alter table conf add mal2 float null
if columnproperty(object_id('conf'),'sepasuser','columnid')  is null alter table conf add sepasuser int null
if columnproperty(object_id('conf'),'sepaspass','columnid')  is null alter table conf add sepaspass varbinary(128) null
if columnproperty(object_id('conf'),'newcol5','columnid')  is null alter table conf add newcol5 nvarchar(10) null
if columnproperty(object_id('conf'),'ostan','columnid')  is null alter table conf add ostan nvarchar(50) null
if columnproperty(object_id('conf'),'shahrestan','columnid')  is null alter table conf add shahrestan nvarchar(50) null
if columnproperty(object_id('conf'),'codeposti','columnid')  is null alter table conf add codeposti nvarchar(50) null
if columnproperty(object_id('conf'),'shahr','columnid')  is null alter table conf add shahr nvarchar(50) null
if columnproperty(object_id('conf'),'meli','columnid')  is null alter table conf add meli nvarchar(15) null
if columnproperty(object_id('conf'),'shahrcode','columnid')  is null alter table conf add shahrcode int null
if columnproperty(object_id('conf'),'ostancode','columnid')  is null alter table conf add ostancode int null
if columnproperty(object_id('conf'),'regno','columnid')  is null alter table conf add regno nvarchar(13) null
if columnproperty(object_id('conf'),'edarehcode','columnid')  is null alter table conf add edarehcode smallint null
if columnproperty(object_id('conf'),'username','columnid')  is null alter table conf add username nvarchar(20) null
if columnproperty(object_id('conf'),'band','columnid')  is null alter table conf add band smallint null
if columnproperty(object_id('conf'),'sabtenam','columnid')  is null alter table conf add sabtenam smallint null
if columnproperty(object_id('conf'),'dar1','columnid')  is null alter table conf add dar1 float null
if columnproperty(object_id('conf'),'dar2','columnid')  is null alter table conf add dar2 float null
if columnproperty(object_id('conf'),'dar3','columnid')  is null alter table conf add dar3 float null
if columnproperty(object_id('conf'),'anbroz','columnid')  is null alter table conf add anbroz smallint null
if columnproperty(object_id('conf'),'anbmah','columnid')  is null alter table conf add anbmah smallint null
if columnproperty(object_id('conf'),'anbsal','columnid')  is null alter table conf add anbsal smallint null
if columnproperty(object_id('conf'),'smsurl','columnid')  is null alter table conf add smsurl nvarchar(30) null
if columnproperty(object_id('conf'),'crmpath','columnid')  is null alter table conf add crmpath nvarchar(200) null
if columnproperty(object_id('conf'),'webhes','columnid')  is null alter table conf add webhes int null
if columnproperty(object_id('conf'),'webuser','columnid')  is null alter table conf add webuser int null
if columnproperty(object_id('conf'),'webpass','columnid')  is null alter table conf add webpass varbinary(128) null
if columnproperty(object_id('conf'),'newcol6','columnid')  is null alter table conf add newcol6 nvarchar(10) null
if columnproperty(object_id('conf'),'boolvar1','columnid')  is null alter table conf add boolvar1 nvarchar(255) null
if columnproperty(object_id('conf'),'modir','columnid')  is null alter table conf add modir nvarchar(100) null
if columnproperty(object_id('conf'),'irani','columnid')  is null alter table conf add irani bit null
if columnproperty(object_id('conf'),'mobileno','columnid')  is null alter table conf add mobileno nvarchar(11) null
if columnproperty(object_id('taraf'),'payamak','columnid')  is null alter table taraf add payamak bit null
if columnproperty(object_id('taraf'),'sefok','columnid')  is null alter table taraf add sefok bit null
if columnproperty(object_id('taraf'),'sefbillok','columnid')  is null alter table taraf add sefbillok bit null
if columnproperty(object_id('taraf'),'sefup','columnid')  is null alter table taraf add sefup bit null
if columnproperty(object_id('taraf'),'ostan','columnid')  is null alter table taraf add ostan nvarchar(50) null
if columnproperty(object_id('taraf'),'shahrestan','columnid')  is null alter table taraf add shahrestan nvarchar(50) null
if columnproperty(object_id('taraf'),'codeposti','columnid')  is null alter table taraf add codeposti nvarchar(50) null
if columnproperty(object_id('taraf'),'shahr','columnid')  is null alter table taraf add shahr nvarchar(50) null
if columnproperty(object_id('taraf'),'meli','columnid')  is null alter table taraf add meli nvarchar(15) null
if columnproperty(object_id('taraf'),'nodechecked','columnid')  is null alter table taraf add nodechecked integer null
if columnproperty(object_id('taraf'),'spc1','columnid')  is null alter table taraf add spc1 float null
if columnproperty(object_id('taraf'),'spc2','columnid')  is null alter table taraf add spc2 float null
if columnproperty(object_id('taraf'),'spc3','columnid')  is null alter table taraf add spc3 float null
if columnproperty(object_id('taraf'),'spc4','columnid')  is null alter table taraf add spc4 float null
if columnproperty(object_id('taraf'),'sefendvas','columnid')  is null begin alter table taraf add sefendvas float null update conf set intg17=0 end
if columnproperty(object_id('taraf'),'pos','columnid')  is null alter table taraf add pos smallint null
if columnproperty(object_id('taraf'),'shahrcode','columnid')  is null alter table taraf add shahrcode int null
if columnproperty(object_id('taraf'),'ostancode','columnid')  is null alter table taraf add ostancode int null
if columnproperty(object_id('taraf'),'n1','columnid')  is null alter table taraf add n1 smallint null
if columnproperty(object_id('taraf'),'n2','columnid')  is null alter table taraf add n2 smallint null
if columnproperty(object_id('taraf'),'anbcode','columnid')  is null alter table taraf add anbcode smallint null
if object_id('khmisc') is null create table khmisc(sqlind int identity not null primary key,fcode int null ,pr smallint null ) 
if columnproperty(object_id('khmisc'),'webup','columnid')  is null alter table khmisc add webup bit null
if columnproperty(object_id('khmisc'),'webup1','columnid')  is null alter table khmisc add webup1 bit null
if columnproperty(object_id('khmisc'),'pr1','columnid')  is null alter table khmisc add pr1 smallint null 
if columnproperty(object_id('khmisc'),'typ','columnid')  is null alter table khmisc add typ smallint null
if columnproperty(object_id('khmisc'),'saat','columnid')  is null alter table khmisc add saat nvarchar(20) null 
if object_id('serialnew') is null create table serialnew(sqlind int identity not null primary key,[Kcode] [int] NULL,[sqlind1] [int] NULL,[Serial] [float] NULL,[gindex] [bigint] NULL,[gindex1] [bigint] NULL,[typ] [smallint] NULL,[anbcode] [smallint] NULL,[tarikh] [int] NULL)
if columnproperty(object_id('serialnew'),'webup','columnid')  is null alter table serialnew add webup bit null
if columnproperty(object_id('serialnew'),'webup1','columnid')  is null alter table serialnew add webup1 bit null
if columnproperty(object_id('serialnew'),'sqlind1','columnid')  is null alter table serialnew add sqlind1 integer null
if columnproperty(object_id('serialnew'),'gindex1','columnid')  is null alter table serialnew add gindex1 bigint null
if columnproperty(object_id('sandog'),'aks','columnid') is not null alter table sandog drop column aks
if object_id('jav') is null create table jav(sqlind int identity not null primary key,code int null ,tarikh1 int null ,Sal1 smallint null ,Mah1 smallint null ,Roz1 smallint null ,vazn1 float null ,tcode int null ,kcode int null ,kvazn float null ,kted float null ,kted2 float null ,kgh1 float null ,kojrat1 float null ,ghkol1 float null ,fanb smallint null ,tarikh2 int not null ,Sal2 smallint null ,Mah2 smallint null ,Roz2 smallint null ,vazn2 float null ,kgh2 float null ,kojrat2 float null ,ghkol2 float null ,kasry float null ,darsad float null ,ghkol float null )
if columnproperty(object_id('jav'),'webup','columnid')  is null alter table jav add webup bit null
if columnproperty(object_id('jav'),'webup1','columnid')  is null alter table jav add webup1 bit null
if columnproperty(object_id('jav'),'kvazn2','columnid') is null alter table jav add kvazn2 float null
if columnproperty(object_id('jav'),'tlcode','columnid') is null alter table jav add tlcode float null
if object_id('javpre') is null create table javpre (sqlind int identity not null primary key,tcode int null ,kcode int null ,kname nvarchar(50) null ,gh1 float null ,gh2 float null )
if columnproperty(object_id('javpre'),'webup','columnid')  is null alter table javpre add webup bit null
if columnproperty(object_id('javpre'),'webup1','columnid')  is null alter table javpre add webup1 bit null
if object_id('sms') is null create table sms(sqlind int identity not null primary key,mobile nvarchar(15) null ,sh nvarchar(1000) null ,tarikh1 nvarchar(25) null ,tarikh2 nvarchar(25) null ,tarikh3 nvarchar(25) null ,mab smallint null ,node1 int null ,node2 int null ,tcode int null ,peygiri int null)
if columnproperty(object_id('sms'),'webup','columnid')  is null alter table sms add webup bit null
if columnproperty(object_id('sms'),'webup1','columnid')  is null alter table sms add webup1 bit null
alter table sms alter column peygiri bigint
if columnproperty(object_id('sms'),'rectype','columnid') is null alter table sms add rectype smallint null
if columnproperty(object_id('sms'),'recno','columnid') is null alter table sms add recno bigint null
if columnproperty(object_id('sms'),'nodechecked','columnid') is null alter table sms add nodechecked integer null
if object_id('talgh') is null create table talgh(sqlind int identity not null primary key,sal int null ,mah int null ,roz int null ,tarikh int null ,gh float null )
if columnproperty(object_id('talgh'),'webup','columnid')  is null alter table talgh add webup bit null
if columnproperty(object_id('talgh'),'webup1','columnid')  is null alter table talgh add webup1 bit null
if object_id('crm') is null create table crm (sqlind int identity not null primary key,tcode int null,node1 smallint null ,tarikh1 nvarchar(25) null,sh1 nvarchar(512) null ,media smallint null ,urg smallint null ,typ1 smallint null ,typ2 smallint null,typ3 smallint null ,subject nvarchar(20) null ,tarikh2 nvarchar(25)  null,node2 smallint null ,tarikh3 nvarchar(25)  null,sh2 nvarchar(512) null ,tarikh4 nvarchar(25)  null,tarikh5 nvarchar(25)  null ,node smallint null ,seen1 bit null ,seen2 bit null ,peygiri int null)
if columnproperty(object_id('crm'),'webup','columnid') is null alter table crm add webup bit null
if columnproperty(object_id('crm'),'webup1','columnid') is null alter table crm add webup1 bit null
if columnproperty(object_id('crm'),'attach','columnid') is null alter table crm add attach bit null
update crm set attach=0 where attach is null
if object_id('crmtypes') is null create table crmtypes (sqlind int identity not null primary key,code int null ,name nvarchar(25) null ,node smallint null ,urgday smallint null)
if columnproperty(object_id('crmtypes'),'webup','columnid')  is null alter table crmtypes add webup bit null
if columnproperty(object_id('crmtypes'),'webup1','columnid')  is null alter table crmtypes add webup1 bit null
if object_id('netlock') is null create table netlock (sqlind int identity not null primary key,nettbname nvarchar(20) null ,netkeyname nvarchar(20) null ,netkeyvalue nvarchar(20) null ,node int null)
if object_id('tarafghroh') is null create table tarafghroh (sqlind int identity not null primary key,code int null,name nvarchar(30) null ,ucode float null,node float null,ghr1 float null,ghr2 float null,ghr3 float null,ghr4 float null,ghr5 float null,ghr6 float null,ghr7 float null,ghr8 float null,ghr9 float null,ghr10 float null,webup bit null)
if columnproperty(object_id('tarafghroh'),'webup1','columnid') is null alter table tarafghroh add webup1 bit null
if object_id('arzgh') is null create table arzgh(sqlind int identity not null primary key,sal int null,mah int null,roz int null,tarikh int null,gh float null,arzcode float null,z1 float null,z2 float null)
if object_id('webdelete') is null create table webdelete(sqlind int identity not null primary key,dbname nvarchar(30) null,fname nvarchar(30) null ,fvalue bigint null)
if columnproperty(object_id('tasvor'),'sefup','columnid')  is null alter table tasvor add sefup bit
if object_id('kalajav') is null CREATE TABLE kalajav(sqlind int identity not null primary key,kcode int null,scode int null,vazn float null)
if object_id('tahvil') is null CREATE TABLE tahvil(sqlind int identity not null primary key,ucode nvarchar(30) null,kcode int null,ted int null,fcode int null)
if columnproperty(object_id('taraf'),'sefmojok','columnid')  is null alter table taraf add sefmojok bit
if columnproperty(object_id('taraf'),'sefmanok','columnid')  is null alter table taraf add sefmanok bit
if columnproperty(object_id('roznameh'),'nodechecked','columnid')  is null alter table roznameh add nodechecked integer null
if columnproperty(object_id('vorod'),'nodechecked','columnid')  is null alter table vorod add nodechecked integer null
if columnproperty(object_id('khoroj'),'nodechecked','columnid')  is null alter table khoroj add nodechecked integer null
if columnproperty(object_id('roznameh'),'tickbes','columnid')  is null alter table roznameh add tickbes bit null
if columnproperty(object_id('tashim2'),'typ','columnid')  is null alter table tashim2 add typ nvarchar(10) null
if columnproperty(object_id('gtcode'),'sefup','columnid')  is null alter table gtcode add sefup bit null 
if object_id('stabdilazad') is null CREATE TABLE [dbo].[stabdilazad](sqlind int identity not null primary key,[Roz] [smallint] NULL,[Mah][smallint] NULL,[Sal] [smallint] NULL,[Tarikh] [int] NULL,[Sh] [nvarchar](60) NULL,[Ticked] [bit] NULL,[Checked] [bit] NULL,[Node] [float] NULL,[Project] [smallint] NULL,[s_unique] [float] NULL,[Fshom] [float] NULL,[webup] [bit] NULL)
if columnproperty(object_id('stabdilazad'),'webup1','columnid')  is null alter table stabdilazad add webup1 bit null
if object_id('stabdilazadr') is null CREATE TABLE [dbo].[stabdilazadr]([gindex] [bigint] NOT NULL primary key,[s_Index] [int] NULL,[Fcode] [int] NULL,[Anbcode1] [int] NULL,[Kcode1] [int] NULL,[Ted1] [float] NULL,[Gh1] [float] NULL,[Anbcode2] [int] NULL,[Kcode2] [int] NULL,[Ted2] [float] NULL,[Gh2] [float] NULL,[Ticked] [bit] NULL,[Checked] [bit] NULL,[Sh] [nvarchar](50) NULL,[Project] [smallint] NULL,[Node] [float] NULL,[webup] [bit] NULL)
if columnproperty(object_id('stabdilazadr'),'webup1','columnid')  is null alter table stabdilazadr add webup1 bit null
if object_id('calender') is null CREATE TABLE [dbo].[calender]([sqlind] [int] IDENTITY(1,1) NOT NULL,[roz] [smallint] NULL,[mah] [smallint] NULL,[sal] [smallint] NULL,[tarikh] [int] NULL,[sh] [nvarchar](255) NULL,[type] [nvarchar](15) NULL,[node] [smallint] NULL,	[darad] [nvarchar](5) NULL,[webup] [bit] NULL)
if columnproperty(object_id('calender'),'webup1','columnid')  is null alter table calender add webup1 bit null
if columnproperty(object_id('calender'),'nodeto','columnid')  is null alter table calender add nodeto smallint null
update calender set nodeto=node where nodeto is null
if columnproperty(object_id('calender'),'nodetoname','columnid')  is null alter table calender add nodetoname nvarchar(25) null
alter table repcon1 alter column tcaption1 nvarchar(20)
alter table repcon1 alter column tcaption2 nvarchar(20)
alter table repcon1 alter column tcaption3 nvarchar(20)
alter table repcon1 alter column tcaption4 nvarchar(20)
alter table repcon1 alter column tcaption5 nvarchar(20)
alter table repcon1 alter column tcaption6 nvarchar(20)
alter table repcon1 alter column tcaption7 nvarchar(20)
alter table repcon1 alter column tcaption8 nvarchar(20)
alter table repcon1 alter column tcaption9 nvarchar(20)
alter table repcon1 alter column tcaption10 nvarchar(20)
alter table repcon1 alter column tcaption11 nvarchar(20)
alter table repcon1 alter column tcaption12 nvarchar(20)
alter table repcon1 alter column tcaption13 nvarchar(20)
alter table repcon1 alter column tcaption14 nvarchar(20)
alter table repcon1 alter column tcaption15 nvarchar(20)
alter table repcon1 alter column tcaption16 nvarchar(20)
if object_id('ticket') is null CREATE TABLE ticket([sqlind] [int] IDENTITY(1,1) NOT NULL,[serial] [int] NOT NULL,[subserial] [int] NULL,	[subject] [nvarchar](100),[owner] [int] NULL,[count] [smallint] NULL,[ownername] [nvarchar](50) NULL,[dt] [nvarchar](30) NULL,	[type] [nvarchar](50) NULL,[city] [nvarchar](50) NULL,[dep] [nvarchar](50) NULL,[program] [nvarchar](50) NULL,[depcode] [smallint] NULL,[programcode] [smallint] NULL,[sh] [ntext] NULL,[whosee] [nvarchar](4) NULL,[howdo] [smallint] NULL,[closed] [nvarchar](15) NULL,[howdosh] [nvarchar](50) NULL,[sqlindsite] [int] NULL,[dtup] [nvarchar](30) NULL,[doit] [bit] NULL,[node] [float] NULL,[fname] [nvarchar](255) NULL,[webup] [bit] NULL)
if columnproperty(object_id('ticket'),'webup1','columnid')  is null alter table ticket add webup1 bit null
alter table [check] alter column shom bigint
alter table [dcheck] alter column shomf bigint
alter table [resid2] alter column shom bigint
alter table [barg] alter column shom bigint
alter table [khfil] alter column fshom1 bigint
alter table [khfil] alter column fshom2 bigint
alter table [khfil] alter column fshom21 bigint
alter table [khfil] alter column fshom22 bigint
alter table [vrfil] alter column fshom1 bigint
alter table [vrfil] alter column fshom2 bigint
alter table [vrfil] alter column fshom21 bigint
alter table [vrfil] alter column fshom22 bigint
if columnproperty(object_id('special1'),'sefup','columnid')  is null alter table special1 add sefup bit
if columnproperty(object_id('taraf'),'toznewcode','columnid')  is null alter table taraf add toznewcode int
if columnproperty(object_id('taraf'),'toznewcode1','columnid')  is null alter table taraf add toznewcode1 int
if columnproperty(object_id('calender'),'darad','columnid')  is null alter table calender add darad nvarchar(5)
alter table [crm] alter column typ2 int
alter table [crm] alter column typ3 int
if columnproperty(object_id('profile'),'tghr1','columnid')  is null alter table profile add tghr1 float null
if columnproperty(object_id('profile'),'tghr2','columnid')  is null alter table profile add tghr2 float null
if columnproperty(object_id('tarafs'),'ghr','columnid')  is null alter table tarafs add ghr float null
if columnproperty(object_id('vrfil'),'ftype9','columnid')  is null alter table vrfil add ftype9 bit null
if columnproperty(object_id('khfil'),'ftype9','columnid')  is null alter table khfil add ftype9 bit null
if columnproperty(object_id('vorodr'),'tam1','columnid')  is null alter table vorodr add tam1 tinyint null
if columnproperty(object_id('vorodr'),'tam2','columnid')  is null alter table vorodr add tam2 tinyint null
if columnproperty(object_id('vorodr'),'tam3','columnid')  is null alter table vorodr add tam3 tinyint null
if columnproperty(object_id('taraf'),'crsal','columnid')  is null alter table taraf add crsal integer null
if columnproperty(object_id('taraf'),'crmah','columnid')  is null alter table taraf add crmah tinyint null
if columnproperty(object_id('taraf'),'crroz','columnid')  is null alter table taraf add crroz tinyint null
update taraf set crsal=0 where crsal is null
update taraf set crmah=0 where crmah is null
update taraf set crroz=0 where crroz is null
if object_id('vorodrr') is null create table vorodrr(gindex bigint primary key ,[roz] [tinyint] NULL,[mah] [tinyint] NULL,[sal] [int] NULL,[Fcode] [int] NULL,[Kcode] [int] NULL,[Ted] [float] NULL,[gh] [float] NULL,[Sh] [nvarchar](50),[s_Index] [int] NULL,[Ticked] [bit] NULL,[Checked] [bit] NULL,[Anbcode] [int] NULL,[Tarikh] [int] NULL,[Node] [float] NULL,[s_Unique] [float] NULL,[webup] [bit] NULL,[tam2] [tinyint] NULL,maliat [float] null)
if columnproperty(object_id('vorodr'),'tam4','columnid')  is null alter table vorodr add tam4 int null
if columnproperty(object_id('vorodr'),'webup1','columnid')  is null alter table vorodr add webup1 bit null
update vorodr set tam1=0 where tam1 is null
update vorodr set tam2=0 where tam2 is null
update vorodr set tam3=0 where tam3 is null
update vorodr set tam4=0 where tam4 is null
if columnproperty(object_id('khfil'),'roz1','columnid')  is null alter table khfil add roz1 tinyint null
if columnproperty(object_id('khfil'),'mah1','columnid')  is null alter table khfil add mah1 tinyint null
if columnproperty(object_id('khfil'),'sal1','columnid')  is null alter table khfil add sal1 smallint null
if columnproperty(object_id('khfil'),'roz2','columnid')  is null alter table khfil add roz2 tinyint null
if columnproperty(object_id('khfil'),'mah2','columnid')  is null alter table khfil add mah2 tinyint null
if columnproperty(object_id('khfil'),'sal2','columnid')  is null alter table khfil add sal2 smallint null
if columnproperty(object_id('vrfil'),'roz1','columnid')  is null alter table vrfil add roz1 tinyint null
if columnproperty(object_id('vrfil'),'mah1','columnid')  is null alter table vrfil add mah1 tinyint null
if columnproperty(object_id('vrfil'),'sal1','columnid')  is null alter table vrfil add sal1 smallint null
if columnproperty(object_id('vrfil'),'roz2','columnid')  is null alter table vrfil add roz2 tinyint null
if columnproperty(object_id('vrfil'),'mah2','columnid')  is null alter table vrfil add mah2 tinyint null
if columnproperty(object_id('vrfil'),'sal2','columnid')  is null alter table vrfil add sal2 smallint null
if columnproperty(object_id('vrfil'),'tarch','columnid')  is null alter table vrfil add tarch bit null
if columnproperty(object_id('khfil'),'tarch','columnid')  is null alter table khfil add tarch bit null
if columnproperty(object_id('conf'),'gsmmodem','columnid')  is null alter table conf add gsmmodem nvarchar(50) null
if columnproperty(object_id('serial1'),'tamircode','columnid')  is null alter table serial1 add tamircode int null
if columnproperty(object_id('khortoz'),'tamircode','columnid')  is null alter table khortoz add tamircode bigint null
alter table [serial1] alter column tamircode bigint
if columnproperty(object_id('kala'),'tamircode','columnid')  is null alter table kala add tamircode int null
alter table taraf alter column titr nvarchar(60)
alter table tarafs alter column titr nvarchar(60)
alter table daftel alter column titr nvarchar(60)
alter table bijak alter column fer nvarchar(60)
if columnproperty(object_id('vorodr'),'takh','columnid')  is null alter table vorodr add takh float
if columnproperty(object_id('khorojr'),'takh','columnid')  is null alter table khorojr add takh float
update vorodr set takh=0 where takh is null
update khorojr set takh=0 where takh is null
if columnproperty(object_id('kalasa'),'exptarikh','columnid') is null exec sp_rename 'kalasa.exp', 'exptarikh', 'COLUMN'
alter table [crm] alter column typ2 bigint
alter table [kala] alter column loc nvarchar(30)
if columnproperty(object_id('kala'),'visloc','columnid')  is null alter table kala add visloc int null
if columnproperty(object_id('vorodr'),'tam5','columnid')  is null alter table vorodr add tam5 int null
update vorodr set tam5=0 where tam5 is null
if columnproperty(object_id('vorodr'),'tam6','columnid')  is null alter table vorodr add tam6 int null
update vorodr set tam6=0 where tam6 is null
if columnproperty(object_id('kala'),'keyw','columnid')  is null alter table kala add keyw nvarchar(50)
update kala set keyw='' where keyw is null
if columnproperty(object_id('kala'),'keyghr','columnid')  is null alter table kala add keyghr nvarchar(50)
update kala set keyghr='' where keyghr is null
if columnproperty(object_id('profile'),'tozcode','columnid')  is null alter table profile add tozcode int null
update profile set tozcode=0 where tozcode is null
if columnproperty(object_id('profile'),'bankcode','columnid')  is null alter table profile add bankcode int null
update profile set bankcode=0 where bankcode is null
if columnproperty(object_id('taraf'),'card','columnid')  is null alter table taraf add card nvarchar(16) null
update taraf set card='' where card is null
if columnproperty(object_id('webdelete'),'webup','columnid')  is null alter table webdelete add webup bit null
update webdelete set webup=0 where webup is null
if columnproperty(object_id('dafkhorr'),'jar','columnid')  is null alter table dafkhorr add jar float null
update dafkhorr set jar=0 where jar is null
if columnproperty(object_id('dafvorr'),'jar','columnid')  is null alter table dafvorr add jar float null
update dafvorr set jar=0 where jar is null
if columnproperty(object_id('stabdilazadr'),'roz1','columnid')  is null alter table stabdilazadr add roz1 smallint null
update stabdilazadr set roz1=0 where roz1 is null
if columnproperty(object_id('stabdilazadr'),'mah1','columnid')  is null alter table stabdilazadr add mah1 smallint null
update stabdilazadr set mah1=0 where mah1 is null
if columnproperty(object_id('stabdilazadr'),'sal1','columnid')  is null alter table stabdilazadr add sal1 smallint null
update stabdilazadr set sal1=0 where sal1 is null
if columnproperty(object_id('stabdilazadr'),'tarikh1','columnid')  is null alter table stabdilazadr add tarikh1 int null
update stabdilazadr set tarikh1=0 where tarikh1 is null
if columnproperty(object_id('stabdilazadr'),'roz2','columnid')  is null alter table stabdilazadr add roz2 smallint null
update stabdilazadr set roz2=0 where roz2 is null
if columnproperty(object_id('stabdilazadr'),'mah2','columnid')  is null alter table stabdilazadr add mah2 smallint null
update stabdilazadr set mah2=0 where mah2 is null
if columnproperty(object_id('stabdilazadr'),'sal2','columnid')  is null alter table stabdilazadr add sal2 smallint null
update stabdilazadr set sal2=0 where sal2 is null
if columnproperty(object_id('stabdilazadr'),'tarikh2','columnid')  is null alter table stabdilazadr add tarikh2 int null
update stabdilazadr set tarikh2=0 where tarikh2 is null
if columnproperty(object_id('special1'),'name2','columnid')  is null alter table special1 add name2 nvarchar(30) null
update special1 set name2='' where name2 is null
if columnproperty(object_id('taraf'),'ramz','columnid')  is null alter table taraf add ramz nvarchar(20) null
update taraf set ramz='' where ramz is null
if object_id('bonus') is null begin create table bonus (sqlind int identity not null primary key,tcode int null,roz smallint null,mah smallint null,sal smallint null,tarikh int null,khfshom float null,vrfshom float null,num1 int null,num2 int null,num3 int null,num4 int null,num5 int null,sh nvarchar(50) null,sh1 nvarchar(50) null,sh2 nvarchar(50) null,sh3 nvarchar(50) null,bed float null,bes float null,mandeh float null,vassh nvarchar(4) null,node smallint null,ticked bit null) update conf set intg14=0,intg18=0 end
if columnproperty(object_id('bonus'),'bool1','columnid')  is null alter table bonus add bool1 bit null
update bonus set bool1=0 where bool1 is null
if columnproperty(object_id('bonus'),'bool2','columnid')  is null alter table bonus add bool2 bit null
update bonus set bool2=0 where bool2 is null
if columnproperty(object_id('bonus'),'bool3','columnid')  is null alter table bonus add bool3 bit null
update bonus set bool3=0 where bool3 is null
if columnproperty(object_id('bonus'),'bool4','columnid')  is null alter table bonus add bool4 bit null
update bonus set bool4=0 where bool4 is null
if columnproperty(object_id('bonus'),'bool5','columnid')  is null alter table bonus add bool5 bit null
update bonus set bool5=0 where bool5 is null
if columnproperty(object_id('taraf'),'n3','columnid')  is null alter table taraf add n3 tinyint null
update taraf set n3=0 where n3 is null
if columnproperty(object_id('kala'),'hesab','columnid')  is null alter table kala add hesab tinyint null
update kala set hesab=0 where hesab is null
alter table repcon alter column datafontsize smallint
alter table repcon alter column dtfontsize smallint
alter table repcon alter column specfontsize smallint
alter table repcon alter column srt1 smallint
alter table repcon alter column srt2 smallint
alter table repcon1 alter column width1 float
if columnproperty(object_id('conf'),'branchid','columnid')  is null alter table conf add branchid smallint null
if columnproperty(object_id('conf'),'lastbranchup','columnid')  is null alter table conf add lastbranchup nvarchar(10) null
if columnproperty(object_id('kala'),'bid','columnid')  is null begin alter table kala add bid smallint null exec('update kala set bid=0 where bid is null') end
if columnproperty(object_id('havaleh'),'bid','columnid')  is null begin alter table havaleh add bid smallint null exec('update havaleh set bid=0 where bid is null') end
if columnproperty(object_id('khoroj'),'bid','columnid')  is null begin alter table khoroj add bid smallint null exec('update khoroj set bid=0 where bid is null') end
if columnproperty(object_id('taraf'),'bid','columnid')  is null begin alter table taraf add bid smallint null exec('update taraf set bid=0 where bid is null') end
if columnproperty(object_id('vorod'),'bid','columnid')  is null begin alter table vorod add bid smallint null exec('update vorod set bid=0 where bid is null') end
if columnproperty(object_id('[check]'),'bid','columnid')  is null begin alter table [check] add bid smallint null exec('update [check] set bid=0 where bid is null') end
if columnproperty(object_id('conf'),'weburl','columnid')  is null alter table conf add weburl nvarchar(30) null
if columnproperty(object_id('conf'),'branchstr','columnid')  is null alter table conf add branchstr nvarchar(400) null
if columnproperty(object_id('conf'),'branchconf','columnid')  is null alter table conf add branchconf nvarchar(200) null
if object_id('branchup') is null create table branchup (sqlind int identity not null primary key ,act smallint null  ,tbname nvarchar(20),flname nvarchar(20) null  ,flvalue bigint null ,branchstr nvarchar(400) null)
if columnproperty(object_id('[check]'),'hesshom1','columnid')  is null begin alter table [check] add hesshom1 nvarchar(30) null exec('update [check] set hesshom1=ltrim(str(hesshom,20,0))')  end
if columnproperty(object_id('[barg]'),'hesshom1','columnid')  is null begin alter table [barg] add hesshom1 nvarchar(30) null exec('update [barg] set hesshom1=ltrim(str(hesshom,20,0))')  end
if columnproperty(object_id('[resid2]'),'hesshom1','columnid')  is null begin alter table [resid2] add hesshom1 nvarchar(30) null exec('update [resid2] set hesshom1=ltrim(str(hesshom,20,0))')  end
if object_id('onlinesh1') is null create table onlinesh1 (sqlind int identity not null primary key ,dum1 smallint null  ,dum2 nvarchar(30) null  ,sh ntext null)
if columnproperty(object_id('[serial1]'),'gindex1','columnid')  is null begin alter table [serial1] add gindex1 bigint null exec('update [serial1] set gindex1=0')  end
if columnproperty(object_id('[profile]'),'khpr2','columnid')  is null begin alter table [profile] add khpr2 smallint null exec('update [profile] set khpr2=0')  end
if columnproperty(object_id('[special1]'),'censqlind','columnid')  is null begin alter table [special1] add censqlind bigint null exec('update [special1] set censqlind=0')  end
if columnproperty(object_id('[profile]'),'censqlind','columnid')  is null begin alter table [profile] add censqlind bigint null exec('update [profile] set censqlind=0')  end
if columnproperty(object_id('[conf]'),'censqlind','columnid')  is null begin alter table [conf] add censqlind bigint null exec('update [conf] set censqlind=0')  end
if columnproperty(object_id('[anbar]'),'censqlind','columnid')  is null begin alter table [anbar] add censqlind bigint null exec('update [anbar] set censqlind=0')  end
if columnproperty(object_id('[bankn]'),'censqlind','columnid')  is null begin alter table [bankn] add censqlind bigint null exec('update [bankn] set censqlind=0')  end
if columnproperty(object_id('[kala1]'),'censqlind','columnid')  is null begin alter table [kala1] add censqlind bigint null exec('update [kala1] set censqlind=0')  end
if columnproperty(object_id('profile'),'rozgabl','columnid')  is null alter table profile add rozgabl smallint null
if object_id('branches') is null create table branches(sqlind int identity not null primary key ,anbcode smallint null  ,seri smallint null ,start nvarchar(10) null,sh nvarchar(50) null)
if columnproperty(object_id('[shahr]'),'censqlind','columnid')  is null begin alter table [shahr] add censqlind bigint null exec('update [shahr] set censqlind=0')  end
if columnproperty(object_id('[tasvor]'),'censqlind','columnid')  is null begin alter table [tasvor] add censqlind bigint null exec('update [tasvor] set censqlind=0')  end
if columnproperty(object_id('[khfil]'),'censqlind','columnid')  is null begin alter table [khfil] add censqlind bigint null exec('update [khfil] set censqlind=0')  end
if columnproperty(object_id('[vrfil]'),'censqlind','columnid')  is null begin alter table [vrfil] add censqlind bigint null exec('update [vrfil] set censqlind=0')  end
alter table KHMISC alter column saat nvarchar(30)
if object_id('mes') is null create table mes(sqlind int identity not null primary key,sqlind1 int null,tarikh nvarchar(10) null,subject nvarchar(100) null,sh ntext null,attr nvarchar(255) null,seen bit null)
if columnproperty(object_id('[barg]'),'sh1','columnid')  is null alter table [barg] add sh1 nvarchar(255) null 
update [barg] set sh1='' where sh1 is null
if columnproperty(object_id('[profile]'),'bool1','columnid')  is null begin alter table [profile] add bool1 bit null exec('update [profile] set bool1=0')  end
if columnproperty(object_id('[profile]'),'bool2','columnid')  is null begin alter table [profile] add bool2 bit null exec('update [profile] set bool2=0')  end
if columnproperty(object_id('[profile]'),'bool3','columnid')  is null begin alter table [profile] add bool3 bit null exec('update [profile] set bool3=0')  end
if columnproperty(object_id('[profile]'),'sig','columnid')  is null begin alter table [profile] add sig int null exec('update [profile] set sig=0')  end
if columnproperty(object_id('[profile]'),'sigcol','columnid')  is null alter table [profile] add sigcol nvarchar(100) null 
update [profile] set sigcol=0 where sigcol is null
if columnproperty(object_id('[roznameh]'),'sig','columnid')  is null alter table [roznameh] add sig nvarchar(100) null
update [roznameh] set sig=0 where sig is null
if columnproperty(object_id('[vorod]'),'sig','columnid')  is null alter table [vorod] add sig nvarchar(100) null
update [vorod] set sig=0 where sig is null
if columnproperty(object_id('[khoroj]'),'sig','columnid')  is null alter table [khoroj] add sig nvarchar(100) null
update [khoroj] set sig=0 where sig is null
if columnproperty(object_id('[crm]'),'rozcode','columnid')  is null begin alter table [crm] add rozcode int null exec('update [crm] set rozcode=0')  end
update [khoroj] set sig='' where sig='0'
update [roznameh] set sig='' where sig='0'
update [profile] set sigcol='' where sigcol='0'
update [vorod] set sig='' where sig='0'
if columnproperty(object_id('[project]'),'censqlind','columnid')  is null begin alter table [project] add censqlind bigint null exec('update [project] set censqlind=0')  end
alter table conf alter column smsdomain nvarchar(50)
if columnproperty(object_id('tarafs'),'nodechecked','columnid')  is null alter table tarafs add nodechecked integer null
if columnproperty(object_id('rozshom'),'typ','columnid')  is null alter table rozshom add typ bit null
if columnproperty(object_id('[check]'),'meli','columnid')  is null alter table [check] add meli nvarchar(14) null
if columnproperty(object_id('barg'),'meli','columnid')  is null alter table barg add meli nvarchar(14) null
if columnproperty(object_id('[kala1]'),'typ','columnid')  is null begin alter table [kala1] add typ smallint null exec('update [kala1] set typ=0')  end
if columnproperty(object_id('khoroj'),'vas','columnid')  is null alter table khoroj add vas nvarchar(30) null
if columnproperty(object_id('[anbar1]'),'censqlind','columnid')  is null begin alter table [anbar1] add censqlind bigint null exec('update [anbar1] set censqlind=0')  end
if columnproperty(object_id('[kala]'),'zarib2','columnid')  is null begin alter table [kala] add zarib2 float null exec('update [kala] set zarib2=0')  end
if columnproperty(object_id('taraf'),'birth','columnid')  is null alter table taraf add birth nvarchar(10) null
if columnproperty(object_id('[havaleh]'),'seri','columnid')  is null begin alter table [havaleh] add seri smallint null exec('update [havaleh] set seri=0')  end
if columnproperty(object_id('[havalehr]'),'seri','columnid')  is null begin alter table [havalehr] add seri smallint null exec('update [havalehr] set seri=0')  end
if columnproperty(object_id('[branches]'),'scode','columnid')  is null begin alter table [branches] add scode int null exec('update [branches] set scode=0')  end
if columnproperty(object_id('[branches]'),'mcode','columnid')  is null begin alter table [branches] add mcode int null exec('update [branches] set mcode=0')  end
if columnproperty(object_id('profile'),'mob','columnid')  is null alter table profile add mob nvarchar(15) null
if columnproperty(object_id('vorodr'),'nodechecked','columnid')  is null begin alter table [vorodr] add nodechecked smallint null exec('update [vorodr] set nodechecked=0')  end
if columnproperty(object_id('khorojr'),'nodechecked','columnid')  is null begin alter table [khorojr] add nodechecked smallint null exec('update [khorojr] set nodechecked=0')  end
if columnproperty(object_id('havalehr'),'nodechecked','columnid')  is null begin alter table [havalehr] add nodechecked smallint null exec('update [havalehr] set nodechecked=0')  end
if columnproperty(object_id('tolidr'),'nodechecked','columnid')  is null begin alter table [tolidr] add nodechecked smallint null exec('update [tolidr] set nodechecked=0')  end
if columnproperty(object_id('havaleh'),'nodechecked','columnid')  is null begin alter table [havaleh] add nodechecked smallint null exec('update [havaleh] set nodechecked=0')  end
if columnproperty(object_id('[havaleh]'),'sig','columnid')  is null alter table [havaleh] add sig nvarchar(100) null
update [havaleh] set sig='' where sig is null
