请选择 进入手机版 | 继续访问电脑版

技术控

    今日:18| 主题:54679
收藏本版 (1)
最新软件应用技术尽在掌握

[其他] The Complete Beginner’s Guide to DROP IF EXISTS in SQL SERVER

[复制链接]

立即注册CoLaBug.com会员,免费获得投稿人的专业资料,享用更多功能,玩转个人品牌!

您需要 登录 才可以下载或查看,没有帐号?立即注册

x

The Complete Beginner’s Guide to DROP IF EXISTS in SQL SERVER

The Complete Beginner’s Guide to DROP IF EXISTS in SQL SERVER-1-技术控-drop,table,if,exists,drop,index,if,exists,mysql,drop,if,exists,drop,view,if,exists,drop,if,exists
     In the Series of SQL SERVER 2016 journey , this is our new article. In this article, we are sharing a new cool feature which introduced in SQL SERVER 2016 which is DROP IF EXISTS (DIE) .
  In our development many times it happens that we need to drop a table and as a best practice we write the following syntax as shown in below figure
   

The Complete Beginner’s Guide to DROP IF EXISTS in SQL SERVER

The Complete Beginner’s Guide to DROP IF EXISTS in SQL SERVER-2-技术控-drop,table,if,exists,drop,index,if,exists,mysql,drop,if,exists,drop,view,if,exists,drop,if,exists

   Now, in SQL SERVER 2016 the same task is super easy. You can write the following syntax to drop the table object
   

The Complete Beginner’s Guide to DROP IF EXISTS in SQL SERVER

The Complete Beginner’s Guide to DROP IF EXISTS in SQL SERVER-3-技术控-drop,table,if,exists,drop,index,if,exists,mysql,drop,if,exists,drop,view,if,exists,drop,if,exists

  DROP TABLE IF EXISTS TABLENAME

  The best part is if suppose the object does not exist then  here will be no error execution will continue.
  Let me share one more example of Dropping a stored procedure.
   

The Complete Beginner’s Guide to DROP IF EXISTS in SQL SERVER

The Complete Beginner’s Guide to DROP IF EXISTS in SQL SERVER-4-技术控-drop,table,if,exists,drop,index,if,exists,mysql,drop,if,exists,drop,view,if,exists,drop,if,exists

  Similar, way we can write for following data objects and with the following syntax
     Procedure:-
DROP PROCEDURE IF EXISTS Procedure Name     Assembly:-
  DROP ASSEMBLY IF EXISTS Assembly Name
   ROLENAME :-
  DROP ROLE IF EXISTS ROLENAME
   TRIGGER :-
  DROP TRIGGER IF EXISTS Trigger Name
   VIEW:-
  DROP VIEW IF EXISTS View Name
   RULE:-
  DROP RULE IF EXISTS RULENAME
   Type:-
  DROP TYPE IF EXISTS Type Name
     Database:-
DROP DATABASE IF EXISTS Database Name     Schema:-
  DROP SCHEMA IF EXISTS Schema Name
   User:-
  DROP USER IF EXISTS Username
   SECURITY POLICY:-
  DROP SECURITY POLICY IF EXISTS Policy Name
   View :-
  DROP VIEW IF EXISTS View Name
   FUNCTION:-
  DROP FUNCTION IF EXISTS Function Name
   SEQUENCE:-
  DROP SEQUENCE IF EXISTS Sequence Name
   INDEX :-
  DROP INDEX IF EXISTS Index Name ON Table Name
   Synonym:-
  DROP SYNONYM IF EXISTS Synonym Name
  I like this feature I am sure you will also like this.
  Please, do share your feedback for blog post.
  Enjoy !!



上一篇:Easy to use React routing and state library!
下一篇:第95期
刘述平 发表于 2016-10-16 09:34:55
刘述平要成为整个酷辣虫最为脸熟之人!
回复 支持 反对

使用道具 举报

duck1082 发表于 2016-10-16 15:14:36
天灵灵地灵灵,这次一定是沙发!
回复 支持 反对

使用道具 举报

haix610 发表于 2016-10-16 18:15:07
生,容易。活,容易。生活,不容易。  
回复 支持 反对

使用道具 举报

纪兴胜 发表于 2016-11-18 18:16:54
那些路人甲乙丙丁在年生散场的剧场里将五彩纷呈和苍白无力潇洒的演绎。
回复 支持 反对

使用道具 举报

*滑动验证:
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

我要投稿

推荐阅读


回页顶回复上一篇下一篇回列表
手机版/CoLaBug.com ( 粤ICP备05003221号 | 文网文[2010]257号 )

© 2001-2017 Comsenz Inc. Design: Dean. DiscuzFans.

返回顶部 返回列表