Search code examples
sql-serverstored-procedureswildcardsqlparametersqldbtype

Is it possible to use wildcards in SQL Server Stored Proc parameters?


I am working with a Stored Proc with takes several parameters. It turns out, though, that for one of the params, I need to loop through a list of items and call the SP multiple times. But as I pass the SP every possible value of that type, it would seem more efficient (and simpler) to just bypass the parameter by saying "get them all" by means of a wildcard.

Is it possible to do that, such as with a "*" or a "%" or something?

Theoretically (based on the research I've done), "%" should work, but in my case it's not returning any records. Am I doing something wrong, with this code:

. . .
new SqlParameter()
{
    ParameterName = "@Member",
    SqlDbType = SqlDbType.VarChar,
    Value = '%'
},
. . .

?


Solution

  • No. Without being able to modify the stored procedure code, there is nothing you can pass as a parameter that will act like a wild card.