How to check if a variable has a value in a SQL Server 2008 stored procedure

sql, sql-server

Solution

Try this

if (@name is null or @value = '') //it will indicate whether it contains a value or not

Problem

I need to check whether a variable has a value or not. ``` declare @name varchar(20) set @name = (SELECT Product_Name FROM tb_new_product_Name_id WHERE Product_Name = @productName) if (@name ) // here I need to check it ``` How to do it? thanks

Original source