I want to write a T-SQL query for below conditions.
If the user provides a value for the parameter, run the query with the where clause.
SELECT *
FROM TestDB
WHERE CustomerId = @customer_id
If the user doesn't provide a value for the parameter, I want to return all the data
SELECT *
FROM TestDB
Can I make it work in a single query, for example using ISNULL()
or an alternative, without going for a stored procedure.