--一视图一
if exists(select 1 from sysobjects where name=N'v_ExpenseQry' and type=N'V')
drop view v_ExpenseQry
go
create view v_ExpenseQry
with encryption
as
--一视图二
if exists (select TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS
WHERE TABLE_NAME = 'v_ExpenseQry')
DROP VIEW v_ExpenseQry
GO
create view v_ExpenseQry
with encryption
as
--函数
if exists (select 1 from sysobjects where name =N'fn_pordersearch' and type in (N'Fn',N'IF',N'TF'))
drop function fn_pordersearch
go
create function fn_pordersearch()
returns table
WITH ENCRYPTION
as
return
--存储过程
if exists (select 1 from sysobjects where name=N'pd_InsertsaleAmountAccrualItem' and type=N'P')
drop procedure pd_InsertsaleAmountAccrualItem
go
create procedure pd_InsertsaleAmountAccrualItem(@transferid integer,@amount money,@sodid int,@transerdate datetime='2000-01-01',@istxamount bit=false,@op_id varchar(20))
with encryption
as
---触发器
if exists (select * from sysobjects where id = object_id(N'[Tr_deptTran_Ins]') and OBJECTPROPERTY(id, N'IsTRIGGER') = 1)
Drop Trigger Tr_deptTran_Ins
go
CREAte trigger Tr_deptTran_Ins on deptTran
with encryption
for insert
as
--创建表格
if exists (select 1
from sysobjects
where id = object_id('StorageAgreement')
and type = 'U')
drop table StorageAgreement
go
/*==============================================================*/
/* Table: StorageAgreement */
/*==============================================================*/
create table StorageAgreement (
UID numeric(10) not null, ---主键
StoreID varchar(12) null, ---仓库
AgreementNo varchar(30) null, ---协议号
StorageLocation varchar(50) null, ---存放地
SigningDate datetime null, ---签订日期
ValidityDate datetime null, ---有效期
operator Varchar(20) null, ---操作员
inputdate datetime null, ---输入日期
constraint PK_STORAGEAGREEMENT primary key (UID)
)
go
查询表相关的触发器启用情况:
select 表名=object_name(parent_obj),触发器名=name
,状态=case status & power(2,11) when power(2,11) then '禁用 ' else '启用 ' end
from sysobjects
where type= 'TR '