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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
imitchie: will this check for both NULLS and an empty string. I need to check for both....
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If @SQL IS NOT NULL