if exists(
select
*
from
sys.databases
where
name
=
'FGM_POS'
)
print
'存在'
if exists (
select
*
from
sysobjects
where
id =OBJECT_ID(N
'[FGM_bt_ePlnMain]'
)
and
OBJECTPROPERTY(id,N
'IsUserTable'
)=1)
print
'存在'
if exists (
select
*
from
sysobjects
where
id =OBJECT_ID(N
'dbo.FGM_bt_ePlnMain'
)
and
OBJECTPROPERTY(id,N
'IsUserTable'
)=1)
print
'存在'
if exists (
select
*
from
sysobjects
where
id =OBJECT_ID(N
'[FGM_sp_SyncePlnMain]'
)
and
OBJECTPROPERTY(id,N
'IsProcedure'
)=1)
print
'存在'
if exists (
select
*
from
sysobjects
where
id =OBJECT_ID(N
'dbo.FGM_sp_SyncePlnMain'
)
and
OBJECTPROPERTY(id,N
'IsProcedure'
)=1)
print
'存在'
select
*
into
#
temp
from
dbo.FGM_bt_ConsumInfoDetail_B
if OBJECT_ID (
'tempdb..#temp'
)
is
not
null
print
'存在'
if exists(
select
*
from
tempdb.dbo.sysobjects
where
id=OBJECT_ID(N
'tempdb..#temp'
)
and
type=
'U'
)
print
'存在'
if exists (
select
*
from
sysobjects
where
id=OBJECT_ID(N'[dc_adplan]
') and type='
V
')
print '
存在
'
--或
if exists (select * from sysobjects where id=OBJECT_ID(N'
dbo.dc_adplan
') and type='
V
')
print '
存在
'
--drop view dbo.dc_adplan
--函数是否存在
--if exists (select * from dbo.sysobjects where id = object_id(N’[dbo].[函数名]’) and xtype in (N’FN’, N’IF’, N’TF’))
-- drop function [dbo].[函数名]
if exists (select * from dbo.sysobjects where id=OBJECT_ID (N'
dbo.GetResourceName
')and xtype in (N'
FN
',N'
IF
',N'
TF
'))
print '
存在
'
--或
if exists (select * from dbo.sysobjects where id=OBJECT_ID (N'
[GetResourceName]
')and xtype in (N'
FN
',N'
IF
',N'
TF
'))
print '
存在
'
--drop function dbo.GetResourceName
--列是否存在
--if exists(select * from syscolumns where id=object_id(’表名’) and name=’列名’)
-- alter table 表名 drop column 列名
if exists(select * from syscolumns where id =OBJECT_ID('
FGM_bt_ePlnMain
') and name='
ePlnName
')
print '
存在
'
--alter table 表名 drop column 列名
--判断列是否自自增列
--if columnproperty(object_id('
table
'),'
col’,’IsIdentity’)=1
if COLUMNPROPERTY(object_id (
'FGM_bt_ePlnMain'
),
'ePlnID'
,
'IsIdentity'
)=1
print
'自增列'
else
print
'非'
select
*
from
sys.sysobjects
where
name
=
'FGM_bt_ePlnMain'
SELECT
[
name
],[id],crdate
FROM
sysobjects
where
xtype=
'U'
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· .NET10 - 预览版1新功能体验(一)