日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問(wèn)題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷解決方案
判斷SQL數(shù)據(jù)庫(kù)中函數(shù)、存儲(chǔ)過(guò)程等是否存在的方法

下面為您介紹sql下用了判斷各種資源是否存在的代碼,需要的朋友可以參考下,希望對(duì)您學(xué)習(xí)sql的函數(shù)及數(shù)據(jù)庫(kù)能夠有所幫助。
庫(kù)是否存在
if exists(select * from master..sysdatabases where name=N'庫(kù)名')
print 'exists'
else
print 'not exists'
---------------
-- 判斷要?jiǎng)?chuàng)建的表名是否存在
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[表名]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
-- 刪除表
drop table [dbo].[表名]
GO
---------------
--判斷要?jiǎng)?chuàng)建臨時(shí)表是否存在
If Object_Id('Tempdb.dbo.#Test') Is Not Null
Begin
print '存在'
End
Else
Begin
print '不存在'
End
---------------
-- 判斷要?jiǎng)?chuàng)建的存儲(chǔ)過(guò)程名是否存在
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[存儲(chǔ)過(guò)程名]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
-- 刪除存儲(chǔ)過(guò)程
drop procedure [dbo].[存儲(chǔ)過(guò)程名]
GO
---------------
-- 判斷要?jiǎng)?chuàng)建的視圖名是否存在
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[視圖名]') and OBJECTPROPERTY(id, N'IsView') = 1)
-- 刪除視圖
drop view [dbo].[視圖名]
GO
---------------
-- 判斷要?jiǎng)?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'))
-- 刪除函數(shù)
drop function [dbo].[函數(shù)名]
GO
if col_length('表名', '列名') is null
print '不存在'
select 1 from sysobjects where id in (select id from syscolumns where name='列名') and name='表名'

網(wǎng)站建設(shè)哪家好,找創(chuàng)新互聯(lián)!專注于網(wǎng)頁(yè)設(shè)計(jì)、網(wǎng)站建設(shè)、微信開(kāi)發(fā)、重慶小程序開(kāi)發(fā)、集團(tuán)企業(yè)網(wǎng)站建設(shè)等服務(wù)項(xiàng)目。為回饋新老客戶創(chuàng)新互聯(lián)還提供了龍華免費(fèi)建站歡迎大家使用!


網(wǎng)站名稱:判斷SQL數(shù)據(jù)庫(kù)中函數(shù)、存儲(chǔ)過(guò)程等是否存在的方法
網(wǎng)站鏈接:http://www.5511xx.com/article/dhshhjj.html