Check for Null or Empty In SP
-
Hi, Please let me know how can i check whether the i/p parameters were Null or empty and raise error and let user know that particular parameter is null or empty when he is trying to execute the SP (Stored procedure)....
You mean inside the stored procedure? You can use IS NULL operator:
create procedure foo @param1 decimal as
begin
if @param1 is null
begin
raiserror('param1 is null', 16, 1);
end;
end;exec foo 1;
exec foo null;
The need to optimize rises from a bad design.My articles[^]
-
Hi, Please let me know how can i check whether the i/p parameters were Null or empty and raise error and let user know that particular parameter is null or empty when he is trying to execute the SP (Stored procedure)....
Yes, what Mika said, but you're still better off wrapping a Data Access Layer around your database to check things like that.
-
You mean inside the stored procedure? You can use IS NULL operator:
create procedure foo @param1 decimal as
begin
if @param1 is null
begin
raiserror('param1 is null', 16, 1);
end;
end;exec foo 1;
exec foo null;
The need to optimize rises from a bad design.My articles[^]
create procedure Myproc @myvar1 decimal as begin if @myvar1 is null begin error('@myvar1 is null', 16, 1); end; end;
-
Hi, Please let me know how can i check whether the i/p parameters were Null or empty and raise error and let user know that particular parameter is null or empty when he is trying to execute the SP (Stored procedure)....
-
Hi, Please let me know how can i check whether the i/p parameters were Null or empty and raise error and let user know that particular parameter is null or empty when he is trying to execute the SP (Stored procedure)....
Hi.. check your parameter is null or not. in stored procedure if(parameter is null or parameter ='') begin sql statements end else begin sql statements end or in single query. select * from tbl where parameter is null or parameter =''