随笔分类 -  .SQL Server

摘要:select Age1 from Student where Name = '张三' create nonclustered index Tw on Student(Name) include(Age1) 创建索引时,可以加上这个 include(Age1) 阅读全文
posted @ 2022-07-23 09:46 二维一加零 阅读(13) 评论(0) 推荐(0) 编辑
摘要:option (recompile)使用在语句 select * from Student where id =1 option (recompile) 使用在存储过程 create proc proc_test (@i int) with recompile as select * from St 阅读全文
posted @ 2022-07-23 08:56 二维一加零 阅读(21) 评论(0) 推荐(0) 编辑
摘要:exec 是解决存储过程parameter sniffer 的方式之一; 用法例子: Declare @sql varchar(1000); set @sql = 'select * from Student'; exec (@sql); 阅读全文
posted @ 2022-07-23 08:26 二维一加零 阅读(115) 评论(0) 推荐(0) 编辑
摘要:--使用缓存 exec sp_executesql N'select * from consume where DATE = @t', N'@t DateTime', '2018-12-04 00:00:00.000' 阅读全文
posted @ 2022-07-19 06:54 二维一加零 阅读(22) 评论(0) 推荐(0) 编辑
摘要:SET XACT_ABORT ON 当 SET XACT_ABORT 为 ON 时,如果 Transact-SQL 语句产生运行时错误,整个事务将终止并回滚 SET XACT_ABORT ON BEGIN TRAN --要执行的语句 COMMIT TRAN GO 参考来源: https://blog 阅读全文
posted @ 2022-07-13 07:13 二维一加零 阅读(24) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示