创建存储过程视图触发器表游标
Posted 管风琴在角落
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了创建存储过程视图触发器表游标相关的知识,希望对你有一定的参考价值。
- 1存储过程
1 create procedure dbo.Test 2 ( 3 @BeginDate datetime, 4 5 ) 6 as 7 begin tran 8 select * 9 from dbo.Table 10 where ColumnDate=@BeginDate 11 12 end
- 2视图
1 create view V_Test 2 as 3 select 4 convert(varchar(20),column1) 5 from 6 dbo.Table 7 8 go
- 3触发器
1 create trigger Trg_UpdateTable_Update 2 on Table 3 after for Update/insert/delete 4 as 5 if Update(column1) 6 begin 7 8 Update dbo.Table 9 set column2=value 10 from dbo.Table a,inserted b 11 where a.column3=b.column3 12 13 end
- 4表
1 create table dbo.Table 2 ( 3 column varchar(32) Not null primary Key, --主键不为空 4 column1 varchar(50) null, 5 column2 varchar(50) null, 6 ... 7 )
- 5游标
http://www.cnblogs.com/yuan-jun/p/6505083.html
1 declare @column1 varchar(20),@column2 int 2 3 declare Table cursor 4 for 5 select Id,Name 6 from dbo.Table1 7 8 Open Table 9 Fetch first from Table into @column1,@column2 10 while @@Fetch_Status=0 11 12 begin 13 Update Table set Name=@column2 where Id=@column1 14 Fetch next from Table into @column1,@column2 15 end 16 17 close Table 18 deallocate
以上是关于创建存储过程视图触发器表游标的主要内容,如果未能解决你的问题,请参考以下文章