I have an application that builds dynamic parameterized SQL queries. The following query returns an inner exception of "syntax error at or near "="...
I am thinking it is in the way that I am assigning the parameter to the column name but, I'm not sure. Code follows.
SELECT TOP 50 77 AS Repository, DocID, LastFileDate, ImageCount,
LockedUserID, DocClass, Offline, FileType, OrigFileName, C_CredCardSSN, C_CredCardName,C_CredCardDocType, C_CredCardDocDate, C_CredCardStatus
FROM D77
WHERE C_CredCardSSN
LIKE C_CredCardSSN = @sp1%
ORDER BY C_CredCardSSN,C_CredCardName
EDIT: Thanks to everyone. All of these answers helped. =)
Try just
WHERE C_CredCardSSN LIKE @sp1
or
WHERE C_CredCardSSN LIKE @sp1+'%'
depending on why you had a "%" there (thanks to Joel Coehoorn's comment for pointing out the "%" I'd missed).
Or (in response to your comment) maybe:
WHERE C_CredCardSSN LIKE ''+@sp1