Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
jmoore_2020
Starting Member
1 Post |
Posted - 2010-07-30 : 13:06:18
|
| anyone know how to display which sql input parameters are not in the database? for example select * from table where ID='number,number2,number3,etc'. number 1 and 2 are entry in the database. number 3 is not in the database. i need a statement that will display which numbers have a result and which do not. number 1 has a entry number 2 has an entry number 3 is empty number 4 is empty. etcthanks |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-07-30 : 13:41:20
|
Please be more specific with sample table structure, sample data and sample output. No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
vijayisonly
Master Smack Fu Yak Hacker
1836 Posts |
Posted - 2010-07-30 : 14:00:59
|
quote: Originally posted by jmoore_2020 anyone know how to display which sql input parameters are not in the database? for example select * from table where ID='number,number2,number3,etc'. number 1 and 2 are entry in the database. number 3 is not in the database. i need a statement that will display which numbers have a result and which do not. number 1 has a entry number 2 has an entry number 3 is empty number 4 is empty. etcthanks
If I understand this correctly...you already have a list of numbers that you want to check right?Create a temp table and insert themCREATE TABLE #T (number VARCHAR(100))INSERT #TSELECT 'number1'UNION ALL SELECT 'number2'UNION ALL SELECT 'number3'UNION ALL SELECT 'number4' Join this table to your main table to find the missing values.SELECT a.numberFROM #T aLEFT JOIN table b on a.number = b.IDWHERE b.ID IS NULL |
 |
|
|
|
|
|