I want to rewrite this query so that if @UserName gets passed in a null value then it leaves the Client_User out of the search criteria. I only want it to search by name if the user enters a name in the username textbox on the webform. I’m not sure how to do this.
select * from weblogs.dbo.vwlogs where Log_time between @BeginDate and @EndDAte and client_user=@UserName
select * from weblogs.dbo.vwlogs where Log_time between @BeginDate and @EndDAte and (@UserName IS NULL OR client_user=@UserName)