获得SQL语句的模板,自己写类似readtrace时候用

DECLARE @stmt nvarchar(max);
DECLARE @params nvarchar(max);
EXEC sp_get_query_template
    N'SELECT COUNT( DISTINCT CAST(SomeTable.SERIAL_NUMBER_ID AS CHAR(36)) ) SomeCount FROM SomeTable  WHERE (SomeTable.END_TIME >= ''2008-05-31T16:00:00'' AND SomeTable.END_TIME < ''2009-02-18T15:59:58'' )  AND (SomeTable.SomeID = ''6606fb3f-a0c9-4ff8-9897-66b6430b5e52'' OR SomeTable.SomeID = ''288d2b98-0c0f-44a3-87f4-b459bab13716'' )',
    @stmt OUTPUT,
    @params OUTPUT;

select @stmt
select @params

 

posted @ 2009-04-23 11:17  鞠强  阅读(1000)  评论(0编辑  收藏  举报

hello

world