Link to home
Start Free TrialLog in
Avatar of msyed1
msyed1

asked on

T- SQL Check for String.Empty or Nulls in a Passed Parameter

I have a stored procedure that receives 20 different parameters as fully built Insert queries...The potential exists though that some of those parameters may be passed to the stored-procedure as empty or nulls.  I need to check to make sure that it is not empty or nulls before I actually EXEC the @SQL.  Can someone please let me know how to do that.  A small portion of the Stored Procedure code is attached.  I have arrows pointing to where I need to check the parameter.  Please show me the right way of doing that.   Help!  msyed1.

 
CREATE PROCEDURE dbo.USP_InsertNewConnectionTables
@CONNInsertSQL varchar(6000) 
 
 
AS
 
BEGIN TRANSACTION
Set Nocount On
Declare @SQL varchar (6000)
 
 
Select @SQL = @CONNInsertSQL
If @SQL <>     String.Empty or NULLS     <<<===================
Begin
  EXEC(@SQL)
  IF @@ERROR <> 0
   BEGIN
    ROLLBACK TRANSACTION
    RETURN (214)
   END
END
 
 
 
COMMIT TRANSACTION
Return 55
GO

Open in new window

Avatar of danrosenthal
danrosenthal

How about:
If @SQL IS NOT NULL
ASKER CERTIFIED SOLUTION
Avatar of imitchie
imitchie
Flag of New Zealand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of msyed1

ASKER

imitchie: will this check for both NULLS and an empty string.  I need to check for both....
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial