参考SQL技术内幕写了一段脚本,可以通过这段脚本查看执行指定SQL语句后,系统生成了哪些执行计划.使用时注意以下几点: 修改use MyTest,换成自己的数据库名字. 将 exec sp_page_test TestTable','*','id',20,100,0,'1=1'替换成要测试的SQL语句 该脚本只支持Sql Server 2005及以上版本 set nocount on; use MyTest; --这里使用你自己的数据库 dbcc freeproccache;--清空过程缓存 g
存储过程往拼接的sql语句中传递日期值 declare @start datetime declare @end datetime set @start='2014-3-1' set @end='2014-3-31' ) set @sql=' select * from search_record where (Name!='' or Phone!='') and (thedate between @st and @en )' exec sp_executesql @sql,N'@st date