Friday 15 February 2013

SQL–Overloading !

I came across this recently while considering the best way to create a function to deal with a SQL statement that could accept a varying number of parameters.

SELECT * FROM YourTable WHERE TableId = 2 AND Param1 = '%' AND Param2 = '%';

It means you don't need to use an overload function. Just swap out blank parameters for wildcard characters, meaning you don't need to do anything with the query as well. You could quite easily do this with any database engine, from Access to SQL Server.

No comments:

Post a Comment

Please, no purely anonymous comments, they will be deleted; always use a name for ease of reference by other commenters.