触发器建表方法
来源:互联网 发布:淘宝悠悠球店铺 编辑:程序博客网 时间:2024/06/07 18:54
--定义变量DECLARE @nBase_Id int
DECLARE @stTable_Name nvarchar( 50 )
DECLARE @stSql varchar( 4096 )
--得到插入的基地编号
SELECT @nBase_Id = [Base_Id] FROM inserted
-------------------------创建表格--------------------------------------------
declare @cmd_sql varchar(1500)
set @stTable_Name = 'Data' + convert(varchar,@nBase_Id) ---此处需要注意
------建温湿度历史数据表部分
set @cmd_sql = 'If Not Exists ( select * from dbo.sysobjects where id = object_id(N''' + @stTable_Name + ''' ) and OBJECTPROPERTY(id, N''IsUserTable'') = 1 ) ' +
'begin Create Table ' + @stTable_Name + '(A_Id decimal(18, 0) IDENTITY (1, 1) NOT NULL, '
+ ' Address_Id int NOT NULL DEFAULT (0), '
+ ' Inter_Time datetime NOT NULL DEFAULT (getdate()), '
+ ' Temp_ValueD decimal(18, 1) NOT NULL DEFAULT (0), '
+ ' Wet_ValueD decimal(18, 1) NOT NULL DEFAULT (0), '
+ ' Lux_ValueN int NOT NULL DEFAULT (0), '
+ ' MilliSecond int NULL)'
-----建立索引部分
+ 'Create Clustered Index Data_Inter_Time On ' + @stTable_Name + ' ( Inter_Time )' --- 建立时间聚集索引
+ 'Create NonClustered Index Data_Address_Id On ' + @stTable_Name + '( Address_Id ) end' --- 建立地址ID非聚集索引
-- select len(@cmd_sql) , @cmd_sql
exec (@cmd_sql)
阅读全文
0 0
- 触发器建表方法
- 触发器的命名方法
- Oracle 触发器测试方法
- 表触发器
- oralce触发器中更新本表的方法
- trigger触发器和自定义方法
- sql中建触发器
- 触发器同步表
- 触发器多表删除
- 事务日志& 表&触发器
- 触发器中虚拟表
- 监听表修改触发器
- 触发器对本表操作
- mysql触发器 更新表
- JK触发器驱动表
- 触发器创建表日志
- 触发器
- 触发器
- Struts
- 国际化(i18n)
- 如何查看redis占用内存大小
- 渗透利器之Powershell
- activeMQ,spring的jmstemplate简单例子
- 触发器建表方法
- Struts 拦截器 、
- 开发8年总结下
- Struts2的动态调用的三种方式
- Spring-Boot 使用手记
- Fragment传值-ImagView轮播
- 浅 浅谈原码、补码和反码
- win7系统配置简单web服务器
- ActiveMQ使用spring JmsTemplate发送消息(一)