DROP TABLE T_TEST CREATE TABLE T_TEST( ID INT IDENTITY PRIMARY KEY,STATUS BIT ) INSERT INTO T_TEST SELECT 0 GO 100000 INSERT INTO T_TEST SELECT 1 CREATE INDEX IXF_T_TEST_STATUS ON T_TEST(STATUS) WHERE STATUS = 1 UPDATE STATISTICS T_TEST with fullscan DBCC FREEPROCCACHE -- 正常查询 SELECT * FROM T_TEST WHERE STATUS = 1
-- 参数化查询 SP_EXECUTESQL N ' SELECT * FROM T_TEST WHERE STATUS=@STATUS ',N ' @STATUS BIT ', 1