SQL Server parameterized query does not go filter index

Source: Internet
Author: User
Tags filter create index
DROP TABLE t_test
CREATE TABLE t_test (
    ID INT IDENTITY PRIMARY key,status BIT
)
INSERT into T_test SELECT 0 Go
100000
INSERT to t_test SELECT 1
    
CREATE INDEX ixf_t_test_status on T_test (STATUS) WHERE Status=1
U Pdate STATISTICS t_test with fullscan
DBCC freeproccache-
-Normal query
SELECT * from T_test WHERE Status=1


--Parameterized query
sp_executesql n ' SELECT * from t_test WHERE status= @STATUS ', n ' @STATUS BIT ', 1

What makes me so sad?

See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/database/SQLServer/

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.