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
這讓我情何以堪?
查看本欄目