I have a stored procedure that is using a variable
When I print the variable - it prints as being parsed correctly - when I substitute what is printed for the variable in the stored procedure it is pulling the data expected but when i try to use the variable it brings forth no data.
The variable in question is @searchString
Line 28 is the line in question
CREATE PROCEDURE [dbo].[Office_stats]
@searchString varchar( 38 )
IF @searchString IS NULL SET @searchString = '%'
IF @searchString = 'LIKE ''%'' ' SET @searchString = '%'
IF @searchString IS NOT NULL SET @searchString = SUBSTRING (@searchString , CHARINDEX ( ' ', @searchString ) + 1, LEN (@searchString ))
left outer join OfficeEmps on employeeid = acempid and ( acchannelstatus = 'complete' or acchannelstatus = 'WaitForComplete')
left outer join EmpsHistory on chempid = employeeid and chid is not null and chdistrict = ''
left outer join officeNames history on chid= history .cnuid and chid is not null and chdistrict = ''
where worklocation in(
'Blue Room Services' ,
'Green States town' ,
'Estats service' ,
'Valley union' ,
'pringles Office' ,
'Eddies Office' ,
'Bluntsville Center' ,
'Palisdale Center' ,
'Union Station Center'
and deptid in( '523' ,'521' , '525', '529' ,'524' , '631')
and worklocation LIKE @searchString