五月综合激情婷婷六月,日韩欧美国产一区不卡,他扒开我内裤强吻我下面视频 ,无套内射无矿码免费看黄,天天躁,日日躁,狠狠躁

新聞動態(tài)

sql server判斷數(shù)據(jù)庫、表、列、視圖是否存在

發(fā)布日期:2021-12-27 18:16 | 文章來源:站長之家

1 判斷數(shù)據(jù)庫是否存在

if exists (select * from sys.databases where name = '數(shù)據(jù)庫名')
drop database [數(shù)據(jù)庫名]

2 判斷表是否存在

if exists (select * from sysobjects where id = object_id(N'[表名]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [表名]

3 判斷存儲過程是否存在

if exists (select * from sysobjects where id = object_id(N'[存儲過程名]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [存儲過程名]

4 判斷臨時表是否存在

if object_id('tempdb..#臨時表名') is not null
drop table #臨時表名

5 判斷視圖是否存在

--判斷是否存在'MyView52'這個試圖
IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'MyView52')
PRINT '存在'
else
PRINT '不存在'

6 判斷函數(shù)是否存在

-- 判斷要創(chuàng)建的函數(shù)名是否存在
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[函數(shù)名]') and xtype in (N'FN', N'IF', N'TF'))
drop function [dbo].[函數(shù)名]

7 獲取用戶創(chuàng)建的對象信息

SELECT [name],[id],crdate FROM sysobjects where xtype='U'

8 判斷列是否存在

if exists(select * from syscolumns where id=object_id('表名') and name='列名')
alter table 表名 drop column 列名

9 判斷列是否自增列

if columnproperty(object_id('table'),'col','IsIdentity')=1
print '自增列'
else
print '不是自增列'

SELECT * FROM sys.columns WHERE object_id=OBJECT_ID('表名') AND is_identity=1

10 判斷表中是否存在索引

if exists(select * from sysindexes where id=object_id('表名') and name='索引名')
print '存在'
else
print '不存在'

刪除索引 drop index 表名.索引名

或: drop index 索引名 on 表名(貌似2000不行)

11 查看數(shù)據(jù)庫中對象

SELECT * FROM sys.sysobjects WHERE name='對象名' SELECT * FROM sys.sysobjects WHERE name='對象名'

版權(quán)聲明:本站文章來源標(biāo)注為YINGSOO的內(nèi)容版權(quán)均為本站所有,歡迎引用、轉(zhuǎn)載,請保持原文完整并注明來源及原文鏈接。禁止復(fù)制或仿造本網(wǎng)站,禁止在非maisonbaluchon.cn所屬的服務(wù)器上建立鏡像,否則將依法追究法律責(zé)任。本站部分內(nèi)容來源于網(wǎng)友推薦、互聯(lián)網(wǎng)收集整理而來,僅供學(xué)習(xí)參考,不代表本站立場,如有內(nèi)容涉嫌侵權(quán),請聯(lián)系alex-e#qq.com處理。

實時開通

自選配置、實時開通

免備案

全球線路精選!

全天候客戶服務(wù)

7x24全年不間斷在線

專屬顧問服務(wù)

1對1客戶咨詢顧問

在線
客服

在線客服:7*24小時在線

客服
熱線

400-630-3752
7*24小時客服服務(wù)熱線

關(guān)注
微信

關(guān)注官方微信
頂部