func()
select * from table where cond1 and cond2 and col.port in <string> ... goes
end
i passing this string from other function, i may be not be needing this filter(underlined) for some functionality, but i will be using the same function for both the functionalities
i need a string that should tell the sql server to allow all the possible values for that column, so by disabling the filter which i am using...
pls tell me URGENT
Thanks in advance
In your function check if string is empty or not and call a different SQL. ie:
if < string is empty >
select * from myTable where cond1 and cond2
else
select * from myTable where cond1 and cond2 and col.port in < string > ....
endif
I agree with the other answer, but it seems too easy.. Is this a user defined function in T-SQL? Or dynamically built using your .NET code? If dynamic then it is essential that you leave off the (col.port in <string> ... ) part. You will force the thing to go through a table scan otherwise.
If it is in a user defined function, they you might be able to use a value of the string, like NULL and add
and (col.port in <string> or <string> is null)
没有评论:
发表评论