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

msyed1Asked:
Who is Participating?
 
imitchieConnect With a Mentor Commented:
check for both '' and NULL

If ISNULL(@SQL, '') <> ''
0
 
danrosenthalCommented:
How about:
If @SQL IS NOT NULL
0
 
msyed1Author Commented:
imitchie: will this check for both NULLS and an empty string.  I need to check for both....
0
 
danrosenthalConnect With a Mentor Commented:
Either of these should work:

If @SQL IS NOT NULL OR @SQL <> ''

If ISNULL(@SQL, '') <> ''

0
All Courses

From novice to tech pro — start learning today.