I thought of the Union statement...
Something like this:
select num, decode
from tblimpacts
inner join tblImpactDecode
on code = 'a'
where a = 1
and num = 1
union
select num, decode
from tblimpacts
inner join tblImpactDecode
on code = 'b'
where b = 1
and num = 1
union
select num...
It appears by your data, that proj is required in both tables and if something in the other 5 columns matches, then you want to update the 3rd table.
So can you do something like:
table1
INNER JOIN table2
ON 1.proj = 2.proj
WHERE (1.fnd = 1.fnd
OR 1.fnct = 2.fnct
OR 1.obj = 2.obj...
your problem is this line: PRINT @OdorID + @Odor;
@odorid is an int and @odor is a character
So I am guessing you have a number and you are trying to add 'warm' to it
Here is an example of your error...
print 1 + 'warm'
Server: Msg 245, Level 16, State 1, Line 1
Syntax error converting the...
Think of the syntax this way for outer joins...
whatever you put in the on clause will join the two tables.
Then you have your where clause. That will filter the results of the joined tables.
So on a left outer join
where t2.name = 'dave' is in the where clause
the left outer join gives...
The problem is that I don't know how many values are in the comma delimited variable.
That is why I was hoping that there was some way to use the IN keyword and sp_execute without having to break up the comma delimited variable. I like the efficiency of sp_executesql.
So are you saying that there is no way you can use sp_executesql and in the where clause use the keyword IN ()?
I have a solution that is working. I just like the idea of using sp_executesql and was hoping there was a way to use it.
I can use the Execute command and the keyword IN() and it works, but when I try and covert the code to sp_executesql I get an error message
Below is just some sample code to set up a test case senerio.
Does anybody know how to use sp_executesql and the keyword IN()? Is this possible...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.