日期:2014-05-18 浏览次数:20908 次
new SqlParameter("@name", SqlDbType.Varchar) { Value = name };
string sql = "select top 1 * from tb where name = @o"; var para = new SqlParameter("@o", SqlDbType.VarChar) {Value = "ab"}; SqlHelper.ExecuteReader(ReadConnectionString, CommandType.Text, sql, para);
exec sp_executesql N'select top 1 * from tb where name = @o',N'@o nvarchar(2)',@o=N'ab'
exec sp_executesql N'select top 1 * from tb where name = @o',N'@o nvarchar(4)',@o=N'abcd'
--先清空执行计划缓存 DBCC FREESYSTEMCACHE ('ALL') DBCC FREEPROCCACHE GO SELECT * FROM sys.dm_exec_cached_plans WHERE cacheobjtype = 'Compiled Plan' GO exec sp_executesql N'select top 1 * from tb where name = @o',N'@o nvarchar(2)',@o=N'ab' GO SELECT * FROM sys.dm_exec_cached_plans WHERE cacheobjtype = 'Compiled Plan' GO exec sp_executesql N'select top 1 * from tb where name = @o',N'@o nvarchar(4)',@o=N'abcd' GO SELECT * FROM sys.dm_exec_cached_plans WHERE cacheobjtype = 'Compiled Plan' GO
new SqlParameter("@name", SqlDbType.Varchar, 4000) { Value = name };
分享必属极品,感谢楼主分享。
------解决方案--------------------
学无止境
------解决方案--------------------
受教了
------解决方案--------------------
SELECT est.text AS batchtext, SUBSTRING(est.text, (eqs.statement_start_offset/2)+1, (CASE eqs.statement_end_offset WHEN -1 THEN DATALENGTH(est.text) ELSE eqs.statement_end_offset END - ((eqs.statement_start_offset/2) + 1))) AS querytext, eqs.creation_time, eqs.last_execution_time, eqs.execution_count, eqs.total_worker_time, eqs.last_worker_time, eqs.min_worker_time, eqs.max_worker_time, eqs.total_physical_reads, eqs.last_physical_reads, eqs.min_physical_reads, eqs.max_physical_reads, eqs.total_elapsed_time, eqs.last_elapsed_time, eqs.min_elapsed_time, eqs.max_elapsed_time, eqs.total_logical_writes, eqs.last_logical_writes, eqs.min_logical_writes, eqs.max_logical_writes, eqs.query_plan_hash FROM sys.dm_exec_query_stats AS eqs CROSS APPLY sys.dm_exec_sql_text(eqs.sql_handle) AS est ORDER BY eqs.total_physical_reads DESC