I’m scratching my head over this one. My stored procedure is giving me grief with an error message:
SQL Error [4145] [S0001]: An expression of non-boolean type specified in a context where a condition is expected, near 'WHERE'
Here’s what I’m working with:
ALTER PROCEDURE [dbo].[spClientSearch]
(@SearchTerm nvarchar(100),
@AccountID bigint)
AS
BEGIN
SELECT DISTINCT
CL.accountid,
A.AccountNumber,
A.AccountName,
searchid,
csd.Details
FROM
MYDB_3515_2.DBO.clientList CL
INNER JOIN
MYDB_3515_2.DBO.accAccounts A ON CL.accountid = A.accountid
INNER JOIN
MYDB_3515_2.DBO.clientSearchDetails csd ON csd.searchID
WHERE
Details LIKE '%'+@SearchTerm+'%'
AND CL.accountid IN (SELECT accountid
FROM MYDB_3515_2.DBO.accAccounts A
WHERE A.AccountNumber = @AccountID)
END
Can anyone spot what’s causing this inner join hiccup? I’ve been staring at it for ages and can’t figure it out. Thanks for any help!
Hmm, interesting problem! Have u considered the possibility of a typo in ur table names? Sometimes those sneaky little errors can cause big headaches. maybe double-check if MYDB_3515_2 is the correct database name? Also, wat happens if u try simplifying the query first, then adding complexity gradually? Just curious about ur approach!
hey ava, looks like ur missing the join condition for clientSearchDetails. try adding ON csd.searchID = CL.searchid or whatever column matches. that should fix the error. goodluck!
I believe I’ve identified the issue in your stored procedure. The problem lies in the INNER JOIN for the clientSearchDetails table. You’ve omitted the join condition, which is causing SQL to misinterpret the WHERE clause. To resolve this, you need to specify how clientSearchDetails relates to the other tables in your query. Assuming there’s a column in clientList that corresponds to searchID, your join might look something like this: INNER JOIN MYDB_3515_2.DBO.clientSearchDetails csd ON csd.searchID = CL.searchID. Once you add the proper join condition, the error should resolve itself. Remember, every INNER JOIN needs an ON clause to define the relationship between the tables. Double-check your table structures to ensure you’re using the correct columns for the join.