28 September 2007

MSSQL Parameters

When I was working on a quick store procedure with optional parameters and preferred not to have to write dozens of if's in TSQL I came upon this page that made my life a little easier (a fairly simple trick, but I thought I'd share):


http://www.dreamincode.net/forums/index.php?s=5f25c46f1fe8351df7ce06b67b58dfeb&showtopic=32431&pid=250875&st=0&#entry250875

Excerpt:

ALTER PROCEDURE dbo.YourProcedureName
@value1 CHAR(100) = NULL,
@value2 CHAR(100) = NULL,
@value3 CHAR(100) = NULL,
@value4 CHAR(100) = NULL
AS
SELECT
column1,
column2,
column3,
column4
FROM
Table_Name
WHERE
((@value1 IS NULL) OR (column1 = @value1))
AND ((@value2 IS NULL) OR (column2 = @value2))
AND ((@value3 IS NULL) OR (column3 = @value3))
AND ((@value4 IS NULL) OR (column4 = @value4))

26 September 2007

AjaxPro

Looks like someone has written a library that allows ridiculous functionality in JavaScript to .net communication.

I can't wait to use it: http://ajaxpro.schwarz-interactive.de/