zoukankan      html  css  js  c++  java
  • SqlServer存在并删除 表,函数,view等

    --表

    if exists (select * from dbo.sysobjects where id = object_id(N'[monthly_budget_work]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
    drop table [monthly_budget_work]
    GO

    --函数

    if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[fn_all_date_in_term]') and xtype in (N'FN', N'IF', N'TF'))
    drop function [dbo].[fn_all_date_in_term]
    GO

    --View

    if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[view_loss]') and OBJECTPROPERTY(id, N'IsView') = 1)
    drop view [dbo].[view_loss]
    GO

    --Trigger

    if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[InsertTrigger_postrn]') and OBJECTPROPERTY(id, N'IsTrigger') = 1)
    drop trigger [dbo].[InsertTrigger_postrn]
    GO

    --SP

    IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sp_download_sales_for_hojinkan]') AND type in (N'P', N'PC'))
    DROP PROCEDURE [dbo].[sp_download_sales_for_hojinkan]
    GO

    --synonyms

    IF EXISTS (SELECT * FROM sys.synonyms WHERE name = N'FEP_kbn_manage')
    DROP SYNONYM [dbo].[FEP_kbn_manage]
    GO

    --assemblies

    IF EXISTS (SELECT * FROM sys.assemblies asms WHERE asms.name = N'SqlServerDebug')
    DROP ASSEMBLY [SqlServerDebug]
    GO

    --FK

    if exists(select *  from sysobjects where name='fk_foreignkey1' and xtype='F')
    ALTER TABLE dbo.table1 DROP CONSTRAINT fk_foreignkey1
    GO

  • 相关阅读:
    数据库从别的数据库查询一张表在插入到新的数据库里面
    html5 学习随笔 1
    .net MVC 学习笔记 (一)
    Html5 本地存储
    .net MVC 学习笔记 (二)
    蝙蝠侠解救罗宾的问题
    求职的第一面Harman
    求职第七面——烽火通讯
    求职的第二面—Samsung
    求职第六面——瑞星微电子
  • 原文地址:https://www.cnblogs.com/puxian/p/4587250.html
Copyright © 2011-2022 走看看