--修改列名
EXEC sp_rename '表名.[旧列名]', '新列名' , 'COLUMN'
GO
--添加列
IF COL_LENGTH('ResultB','wufhzz') IS NULL
BEGIN
ALTER TABLE ResultB ADD wufhzz nchar(6)
END
GO
--修改列类型
IF COL_LENGTH('VTR_AJ_ManualAudit_YQ','JYJG') IS NOT NULL
BEGIN
ALTER TABLE VTR_AJ_ManualAudit_YQ ALTER COLUMN JYJG VARCHAR(100)
END
go
-- 判断要创建的存储过程名是否存在,存在则删除
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[p_ZJLW_AQJS_BZ]') AND OBJECTPROPERTY(object_id,N'IsProcedure')=1)
DROP PROCEDURE [dbo].[p_ZJLW_AQJS_BZ]
GO
--视图存在,删除视图
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[V_ZJLW_VEH_38900_1]') and OBJECTPROPERTY(id,N'IsView') = 1)
Drop View [dbo].[V_ZJLW_VEH_38900_1]
go
--判断表是否存在,不存在就创建表
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ResultOtherFace]') AND type in (N'U'))
BEGIN
创建表语句
end
go
IF NOT EXISTS(select top 1* from sysobjects where xtype='U' and name='VTR_SpecialCase')
BEGIN
创建表语句
end
go
--判断表中数据是否存在,不存在则插入
IF NOT EXISTS (SELECT * FROM CT_SYS_OI_ENCODE WHERE OI_NAME='使用性质' and OI_VALUE='预约出租客运')
BEGIN
INSERT INTO [dbo].[CT_SYS_OI_ENCODE] ([ID], [OI_NAME], [OI_VALUE], [LINK_CODE]) VALUES (3534, N'使用性质', N'预约出租客运', N'T')
END
GO
IF NOT EXISTS (SELECT * FROM CT_SYS_OI_ENCODE WHERE OI_NAME='使用性质' and OI_VALUE='预约出租转非')
BEGIN
INSERT INTO [dbo].[CT_SYS_OI_ENCODE] ([ID], [OI_NAME], [OI_VALUE], [LINK_CODE]) VALUES (3535, N'使用性质', N'预约出租转非', N'U')
END
GO