SQL Server Templates - How Do I Escape The Less Than Character?

前端 未结 2 1566
无人共我
无人共我 2021-01-19 05:59

I like to use SQL Server 2005 templates to run frequently used queries. You can include parameters in your templates using this syntax:



        
2条回答
  •  花落未央
    2021-01-19 06:36

    when I Specify Values for Template Parameters, this runs fine for me:

    select * from  WHERE ID<=1000 AND ID>=20000
    

    perhaps you do not have every parameter's "<" and ">" paired properly

    EDIT I see the problem now:

    SELECT * FROM  WHERE ID<=1000 AND ID>=20000 AND  IS NOT NULL
    

    results in:

    SELECT * FROM YourTable WHERE IDYourColumn IS NOT NULL
    

    try making the "<" character into a parameter, like this:

    SELECT * FROM  WHERE ID=1000
    AND ID>=20000 AND < IS NOT NULL
    

    it results in:

    SELECT * FROM YourTable WHERE ID<=1000
    AND ID>=20000 AND YourColumn IS NOT NULL
    

    OR split the lines, line breaks seem to make a difference:

    SELECT * FROM  WHERE ID<=1000 AND ID>=20000 
    AND  IS NOT NULL
    

    results in:

    SELECT * FROM YourTable WHERE ID<=1000 AND ID>=20000 
    AND YourColumn IS NOT NULL
    

提交回复
热议问题