troubleshooting Question

Conversion failed when converting the nvarchar value 'One' to data type int.

Avatar of johnkainn
johnkainn asked on
Microsoft SQL Server 2005
9 Comments3 Solutions588 ViewsLast Modified:
I have 4 tables
1) test_t1.  Columns: t1Id and wId.  
2) test_t2.  Columns: t2Id and wId.
3) test_w. Columns: wId and Word.   A table with words that the first two tables refer to.
4) test_P.  Columns: PId, t1Id, t2Id.
I created a stored procedures, that gets everything from test_P table and should also get Word from test_w table.  I tried to make a subquery, but I get following error:
Msg 245, Level 16, State 1, Procedure test_TestGet1, Line 12
Conversion failed when converting the nvarchar value 'One' to data type int.
ALTER PROCEDURE [dbo].[test_TestGet1]
	(
	@PId int,
	@t1Id int,
	@t2Id int
	)
AS
	SELECT * FROM test_P p
	JOIN test_t1 a
	ON p.t1Id=a.t1Id
	JOIN test_t2 b
	ON p.t2Id=b.t2Id
	WHERE @PId=1 AND @t1Id=(SELECT w.word FROM test_w w WHERE w.wId=a.wId AND a.t1Id=@t1Id) AND @t2Id=(SELECT w.word FROM test_w w WHERE w.wId=b.wId AND b.t2Id=@t2Id)
ASKER CERTIFIED SOLUTION
Mark Wills
Topic Advisor
Join our community to see this answer!
Unlock 3 Answers and 9 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 3 Answers and 9 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros