Home Forums SQL Server 2008 SQL Server 2008 - General Creation of dynamic sql query to create a select statement to pick a unique record RE: Creation of dynamic sql query to create a select statement to pick a unique record

  • Yes this is not sure whether any of parameter will contain value or not except @city or @zip.

    and also I guess IN clause won't work with a variable containing multiple values

    like the following code will not work:

    select blah from blah where countryId IN (@country)

    You can use the below query if a variable containing multiple values,

    select blah from blah where

    CHARINDEX(LTRIM(RTRIM(CountryId)), @country) > 0