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))

80 Comments:

Anonymous <a href="http://xanax.zzl.org">Xanax</a> said...

wxYOZf Very good blog! Thanks!

November 2, 2007 10:07 AM  
Anonymous <a href="http://users2.titanichost.com/buyviagra/137.html">soma mandal</a> said...

EOimmh Magnific!

November 2, 2007 11:52 AM  
Anonymous <a href="http://free.7host07.com/nmcfgy/54.html">all star tours</a> said...

Nice Article.

November 2, 2007 12:41 PM  
Anonymous <a href="http://fioricet.clanteam.com/?pharma=513">my fioricet foricet migraine</a> said...

Please write anything else!

November 2, 2007 1:26 PM  
Anonymous <a href="http://celebrex.zxq.net/?pharma=12">200 celebrex line vioxx</a> said...

Thanks to author.

November 2, 2007 2:35 PM  
Anonymous <a href="http://m1.aol.com/BrettHead14/180.html">missouri farm mutual insurance companies</a> said...

Magnific!

November 2, 2007 3:35 PM  
Anonymous <a href="http://users2.titanichost.com/buyviagra/index.html">viagra</a> said...

Magnific!

November 3, 2007 5:06 AM  
Anonymous <a href="http://tramadol.newsit.es/deine-nachricht-site-tramadol.html">deine nachricht site tramadol</a> said...

Thanks to author.

November 3, 2007 9:45 AM  
Anonymous <a href="http://tramadol.newsit.es/tramadol-aldara-zyrtec-xenical.html">tramadol aldara zyrtec xenic</a> said...

Hello all!

November 3, 2007 11:42 AM  
Anonymous <a href="http://phentermine.whdot.com/index21.html">buy phentermine with no prescription</a> said...

Good job!

November 3, 2007 12:28 PM  
Anonymous <a href="users2.titanichost.com/amalopra">JohnBraun</a> said...

WmCAOx write more, thanks.

November 4, 2007 7:25 AM  
Anonymous <a href="http://users2.titanichost.com/popebatret/index23.html">college sex ameature</a> said...

actually, that's brilliant. Thank you. I'm going to pass that on to a couple of people.

November 4, 2007 9:51 PM  
Anonymous <a href="http://users2.titanichost.com/inoryum/index34.html">dumb sex acts</a> said...

Good job!

November 4, 2007 10:25 PM  
Anonymous <a href="http://users2.titanichost.com/hviler/index26.html">anime shemale sex</a> said...

Good job!

November 5, 2007 12:15 AM  
Anonymous <a href="http://users2.titanichost.com/ansfur/index13.html">learning anal sex</a> said...

Hello all!

November 5, 2007 12:49 AM  
Anonymous <a href="http://users2.titanichost.com/olds77/index12.html">free anal and cock suking pictures</a> said...

Magnific!

November 5, 2007 1:25 AM  
Anonymous <a href="http://users2.titanichost.com/shingro/index4.html">sex and loving</a> said...

Wonderful blog.

November 5, 2007 1:53 AM  
Anonymous <a href="http://users2.titanichost.com/scersi/index30.html">ebony sex partys</a> said...

Please write anything else!

November 5, 2007 2:24 AM  
Anonymous <a href="http://users2.titanichost.com/t1fielde/index.html">oral sex female</a> said...

Please write anything else!

November 5, 2007 2:56 AM  
Anonymous <a href="http://users2.titanichost.com/adjutes/index14.html">beast stories sex</a> said...

Hello all!

November 5, 2007 3:32 AM  
Anonymous <a href="http://users2.titanichost.com/adjutes/index32.html">beastly sex mpegs</a> said...

Nice Article.

November 5, 2007 4:14 AM  
Anonymous <a href="http://users2.titanichost.com/shiconta/index9.html">couples sex sites</a> said...

actually, that's brilliant. Thank you. I'm going to pass that on to a couple of people.

November 5, 2007 4:52 AM  
Anonymous <a href="http://users2.titanichost.com/gnites3/index.html">horny sex experiences</a> said...

Good job!

November 5, 2007 5:25 AM  
Anonymous <a href="http://users2.titanichost.com/marymeno/index16.html">prostatectomy and sex</a> said...

Hello all!

November 5, 2007 5:55 AM  
Anonymous <a href="http://users2.titanichost.com/vadhoms/index24.html">mariah carry sex</a> said...

Beam me aboard, Scotty..... Sure. Will a 2x10 do?

November 5, 2007 6:30 AM  
Anonymous <a href="http://users2.titanichost.com/etooking/index27.html">nude mother sex</a> said...

Oops. My brain just hit a bad sector.

November 5, 2007 7:08 AM  
Anonymous <a href="http://users2.titanichost.com/swiseny/index10.html">dog hentai sex</a> said...

Friends help you move. Real friends help you move bodies

November 5, 2007 7:39 AM  
Anonymous <a href="http://users2.titanichost.com/Lostsoldier3/index13.html">free pantyhose porn galleries</a> said...

Build a watch in 179 easy steps - by C. Forsberg.

November 5, 2007 8:05 AM  
Anonymous <a href="http://users2.titanichost.com/pyzoid/index33.html">bow wow sex</a> said...

When there's a will, I want to be in it.

November 5, 2007 8:38 AM  
Anonymous <a href="http://users2.titanichost.com/pyzoid/index6.html">bollywood movies sex</a> said...

Hello all!

November 5, 2007 9:11 AM  
Anonymous <a href="http://users2.titanichost.com/selli83/index11.html">advanced sex position</a> said...

Build a watch in 179 easy steps - by C. Forsberg.

November 5, 2007 9:45 AM  
Anonymous <a href="http://users2.titanichost.com/numdaso/index1.html">inuyasha sex doujin</a> said...

Give me ambiguity or give me something else.

November 5, 2007 10:17 AM  
Anonymous <a href="http://users2.TitanicHost.com/beveris/hydromorphone-lorcet.html">hydromorphone lorcet</a> said...

Good job!

November 5, 2007 10:48 AM  
Anonymous <a href="http://cialis.whdot.com/index13.html">cheapest india generic cialis</a> said...

A lot of people mistake a short memory for a clear conscience.

November 5, 2007 11:21 AM  
Anonymous <a href="http://web.archive.org/web/20070818073310/xanga.com/buyultramonline">ultram er</a> said...

What is a free gift ? Aren't all gifts free?

November 5, 2007 11:54 AM  
Anonymous <a href="http://users2.titanichost.com/numdaso/index20.html">japerness force sex</a> said...

The gene pool could use a little chlorine.

November 5, 2007 12:36 PM  
Anonymous <a href="http://users2.titanichost.com/febisko/index.html">bekka phone sex</a> said...

What is a free gift ? Aren't all gifts free?

November 5, 2007 1:15 PM  
Anonymous <a href="http://users2.titanichost.com/topletrufus/index17.html">girlfriends mom sex</a> said...

Suicidal twin kills sister by mistake!

November 5, 2007 1:52 PM  
Anonymous <a href="http://users2.titanichost.com/yetzeit/index19.html">asian sex travel</a> said...

When there's a will, I want to be in it.

November 5, 2007 2:26 PM  
Anonymous <a href="http://users2.titanichost.com/brittanyrogers/index1.html">ametuer sex vedeos</a> said...

Beam me aboard, Scotty..... Sure. Will a 2x10 do?

November 5, 2007 2:58 PM  
Anonymous <a href="http://users2.titanichost.com/glicia80/index26.html">sex aunt polly</a> said...

Thanks to author.

November 5, 2007 3:26 PM  
Anonymous <a href="http://users2.titanichost.com/reekello/index5.html">deck sex drink</a> said...

Magnific!

November 5, 2007 3:53 PM  
Anonymous <a href="http://users2.titanichost.com/tortene/index19.html">online sex vides</a> said...

A lot of people mistake a short memory for a clear conscience.

November 5, 2007 4:22 PM  
Anonymous <a href="http://users2.TitanicHost.com/kiderg/cocaine-elemental-configuration.html">cocaine elementa</a> said...

Friends help you move. Real friends help you move bodies.

November 5, 2007 4:52 PM  
Anonymous name said...

When there's a will, I want to be in it.

November 5, 2007 5:25 PM  
Anonymous <a href="http://users2.titanichost.com/cuhozhilov/index10.html">dragon ball gt hentai porn</a> said...

Friends help you move. Real friends help you move bodies.

November 5, 2007 6:00 PM  
Anonymous <a href="http://users2.titanichost.com/robertf/index3.html">psp video anal porn</a> said...

The gene pool could use a little chlorine.

November 5, 2007 6:34 PM  
Anonymous <a href="http://users2.titanichost.com/maxeevich/index20.html">adult services porn links adult list</a> said...

When there's a will, I want to be in it.

November 5, 2007 7:09 PM  
Anonymous <a href="http://users2.titanichost.com/dityroe/index16.html">lesbo tit sex</a> said...

Calvin, we will not have an anatomically correct snowman!

November 5, 2007 7:41 PM  
Anonymous <a href="http://users2.titanichost.com/liperwo/index12.html">babe lesbian sex</a> said...

Clap on! , Clap off! clap@#&$NO CARRIER

November 5, 2007 8:12 PM  
Anonymous <a href="http://users2.titanichost.com/dasistorama/index14.html">free xxx hardcore porn</a> said...

Good job!

November 5, 2007 8:45 PM  
Anonymous <a href="http://users2.titanichost.com/rego07/index13.html">corn hole porn</a> said...

Lottery: A tax on people who are bad at math.

November 5, 2007 9:27 PM  
Anonymous <a href="http://users2.titanichost.com/artinko/index28.html">hardcore free porn pics</a> said...

Please write anything else!

November 5, 2007 10:10 PM  
Anonymous <a href="http://users2.titanichost.com/lindafmosley/index35.html">arse anal cunt come</a> said...

Wonderful blog.

November 5, 2007 10:42 PM  
Anonymous <a href="http://users2.titanichost.com/tereritoa1/index34.html">fully sex 5</a> said...

A lot of people mistake a short memory for a clear conscience.

November 5, 2007 11:22 PM  
Anonymous <a href="http://users2.titanichost.com/eynol/index27.html">porn thunder pics</a> said...

Ever notice how fast Windows runs? Neither did I.

November 5, 2007 11:58 PM  
Anonymous <a href="http://users2.titanichost.com/dentouj/index9.html">hentai sex doll</a> said...

The gene pool could use a little chlorine.

November 6, 2007 12:30 AM  
Anonymous <a href="http://users2.TitanicHost.com/staer/in-what-countries-is-marijuana-legal.html">in what coun</a> said...

What is a free gift ? Aren't all gifts free?

November 6, 2007 1:11 AM  
Anonymous <a href="http://users2.titanichost.com/bybonte/index32.html">chair liberator sex</a> said...

Suicidal twin kills sister by mistake!

November 6, 2007 1:51 AM  
Anonymous <a href="http://users2.titanichost.com/unareq/index16.html">photo sex gratui</a> said...

Lottery: A tax on people who are bad at math.

November 6, 2007 2:36 AM  
Anonymous <a href="http://users2.titanichost.com/mezers/index12.html">butt teen sex</a> said...

Nice Article.

November 6, 2007 3:24 AM  
Anonymous <a href="http://users2.titanichost.com/deswef/index27.html">cartoon sex directory</a> said...

Lottery: A tax on people who are bad at math.

November 6, 2007 4:07 AM  
Anonymous <a href="http://users2.titanichost.com/tedethe/index13.html">free leabian sex</a> said...

Magnific!

November 6, 2007 4:48 AM  
Anonymous <a href="http://users2.titanichost.com/simpleplayer/index9.html">how make homemade porn</a> said...

Friends help you move. Real friends help you move bodies.

November 6, 2007 5:38 AM  
Anonymous <a href="http://users2.titanichost.com/sobermi/index9.html">indie sex censored</a> said...

Hello all!

November 6, 2007 6:29 AM  
Anonymous <a href="http://users2.titanichost.com/clydej/index2.html">wednesday addams porn</a> said...

What is a free gift ? Aren't all gifts free?

November 6, 2007 7:19 AM  
Anonymous <a href="http://users2.titanichost.com/xcalomi/index4.html">kelleyaic sex sites</a> said...

I'm not a complete idiot, some parts are missing!

November 6, 2007 8:01 AM  
Anonymous <a href="http://users2.titanichost.com/ramisew/index6.html">predict baby sex</a> said...

When there's a will, I want to be in it.

November 6, 2007 8:40 AM  
Anonymous <a href="http://users2.titanichost.com/hegory/index32.html">behind the scenes of a porn movie</a> said...

Save the whales, collect the whole set

November 6, 2007 9:19 AM  
Anonymous <a href="http://users2.titanichost.com/sidspros/index29.html">kiss sex video</a> said...

All generalizations are false, including this one.

November 6, 2007 9:54 AM  
Anonymous <a href="http://users2.titanichost.com/whitedenster/index33.html">brenda bella porn</a> said...

Wonderful blog.

November 6, 2007 10:32 AM  
Anonymous <a href="http://users2.titanichost.com/MarcellaDurant/index29.html">squamous cell anal cancer</a> said...

Suicidal twin kills sister by mistake!

November 6, 2007 11:15 AM  
Anonymous <a href="http://users2.titanichost.com/cationie1/index5.html">perv sex pics</a> said...

Beam me aboard, Scotty..... Sure. Will a 2x10 do?

November 6, 2007 11:56 AM  
Anonymous <a href="http://phentermine.43i.net/323-061107.html">buying phentermine without prescription</a> said...

Save the whales, collect the whole set

November 6, 2007 12:41 PM  
Anonymous <a href="http://phentermine.43i.net/514-061107.html">generic phentermine online consultation</a> said...

actually, that's brilliant. Thank you. I'm going to pass that on to a couple of people.

November 6, 2007 1:30 PM  
Anonymous <a href="http://phentermine.43i.org/477-061107.html">dr consult phentermine</a> said...

A lot of people mistake a short memory for a clear conscience.

November 6, 2007 2:17 PM  
Anonymous <a href="http://users2.titanichost.com/nimytre/index7.html">index sex poses</a> said...

I'm not a complete idiot, some parts are missing!

November 6, 2007 2:54 PM  
Anonymous Anonymous said...

miley cyrus nude miley cyrus nude miley cyrus nude

November 3, 2009 7:55 PM  
Anonymous Anonymous said...

ups sorry delete plz [url=http://duhum.com].[/url]

February 3, 2010 4:03 AM  
Anonymous Anonymous said...

http://markonzo.edu qcncr pinochet http://blog.tellurideskiresort.com/members/paxil-side-effects.aspx http://clarinex.indieword.com/ nocomments cussing http://www.ecometro.com/Community/members/celebrex-side-effects.aspx http://profiles.friendster.com/levaquin#moreabout placeparents enforcememt http://www.netknowledgenow.com/members/ativan-side-effects.aspx http://blog.bakililar.az/famciclovir/ http://profiles.friendster.com/lexapro#moreabout chassis taboo http://blog.tellurideskiresort.com/members/buy-clomid.aspx

February 24, 2010 3:36 PM  

Post a Comment

Links to this post:

Create a Link

<< Home