Home Forums SQL Server 2012 SQL Server 2012 - T-SQL Dynamic SQL Query Not Fetching Records based on where Not In condition RE: Dynamic SQL Query Not Fetching Records based on where Not In condition

  • This code is wildly open to SQL injection. If you don't know what I'm talking about, please google it.
    Scratch that.
    This code has no reason to be dynamic. It also has no reason to use NOT IN.
    It just needs a simple approach:
    SELECT title, titleofcourtesy FROM employees WHERE employeeid <> @employeeid;

    Now, if the code is more complex that what you have shown in here, unscratch the first part and read about SQL injection.

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2