Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
Adagio
Starting Member
5 Posts |
Posted - 2007-04-04 : 08:05:24
|
| I'm building a stored procedure where it should select something based on what information is sent to the sp, but some of the information might be emptyI have something like this:ALTER PROCEDURE dbo.FindQrapport( @DRIVER nvarchar(30) = '%%', @SHPRNO decimal(18, 0) = ??? )ASSELECT ReportNumberFROM ReportHeaderWHERE (DRIVER1 LIKE @DRIVER OR DRIVER2 LIKE @DRIVER) AND SHPRNO = @SHPRNORETURNSometimes this gets called where only @DRIVER is set to something and other times @SHPRNO is the only one with a value. If it's the latter it wont be a problem as @DRIVER has a default value that selects everything, but how do you set this for a decimal? |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-04-04 : 08:07:47
|
quote: Originally posted by Adagio I'm building a stored procedure where it should select something based on what information is sent to the sp, but some of the information might be emptyI have something like this:ALTER PROCEDURE dbo.FindQrapport( @DRIVER nvarchar(30) = '%%', @SHPRNO decimal(18, 0) = Null )ASSELECT ReportNumberFROM ReportHeaderWHERE (DRIVER1 LIKE @DRIVER OR DRIVER2 LIKE @DRIVER) AND (@SHPRNO IS NULL or SHPRNO = @SHPRNO)RETURNSometimes this gets called where only @DRIVER is set to something and other times @SHPRNO is the only one with a value. If it's the latter it wont be a problem as @DRIVER has a default value that selects everything, but how do you set this for a decimal?
Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
Adagio
Starting Member
5 Posts |
Posted - 2007-04-04 : 08:41:01
|
| Thanks, can't believe it was that simple :) |
 |
|
|
|
|
|