473,396 Members | 1,724 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Setting a variable based on a match - Then inserting into a temp table - SQL 2000

Hello,

I have a stored procedure that looks similar to the one below:

Expand|Select|Wrap|Line Numbers
  1.  
  2. Select * from 
  3. table a
  4. inner join
  5. table b
  6. on
  7. a.id = b.id
  8. inner join
  9. table c
  10. on
  11. b.id = c.id
  12. AND
  13. (a.value = b.value    
  14. OR
  15. a.value = c.value
  16. OR
  17. b.value = c.value)
  18.  
How could I set a variable I declare @match, to different values based on how they were matched up in the AND(a.value = b.value OR ... etc. statement ? Also if one matched for one or more how I could I handle that case. The desired result is below:

#temp would be a temporary table with columns id and match

select * from #temp

If it only matched on a
( (1), ("a") )
if it matched on a and b
( (2), ("a,b") )
if it matched on all three
( (3), ("a,b,c") )

and so on...

If anyone has a good example of a stored procedure with such functionality that would be very helpful.

Thanks
Nov 21 '08 #1
0 905

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: tperovic | last post by:
Using SS2K, I'm getting the following error while bulk inserting: Column 'warranty_expiration_date' cannot be modified because it is a computed column. Here is my bulk insert statement: ...
3
by: Tyler Hudson | last post by:
/*Code below raises following errors: Server: Msg 245, Level 16, State 1, Line 6 Syntax error converting the varchar value 'a' to a column of data type int. */ create table #x (i integer, c...
7
by: Philip Mette | last post by:
Does anyone have any good references they could recommend on Cursor based SQL writing? I have to create SQL that can loop though records simular to VB loops and I have been told that this is the...
1
by: Michael Hardy | last post by:
I would like to reopen this discussion. I need to create this table using SQL that will return this dataset. BRAID RATEDEFID MIN(BRADATE) MAX(BRADATE RATECODE PRODNAME 614 14 12/1/2002...
5
by: kmunderwood | last post by:
I am trying to combine "if match=" and "when test" I am a newbie, and have made both work separately, but I can not seem to combine them. This is my xml("index.xml")page(I can not change this,...
2
by: Erich93063 | last post by:
I have made the following test stored proc that all it does right now is accept a string variable that will be a list ie. :5,9,6,13. Right now all the SP is doing is creating a temp table to store...
11
by: Zlatko Matić | last post by:
Hello. I have a MS Access front-end working with PostgreSQL database. I have successfully created saved File DSN. My paa-through queries are referring to that file as well as linked tables. But I...
1
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 on Apache 2 on Fedora Core 5. PHP was installed using Apache's apxs and the php library was installed to /usr/local/php. However, when I set my "error_reporting"...
2
by: Burbletrack | last post by:
Hi All, Hope someone can help me... Im trying to highlight the advantages of using table variables as apposed to temp tables within single scope. My manager seems to believe that table...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.