Quantcast
Channel: SQLServerCentral » SQL Server 2014 » Development - SQL Server 2014 » Latest topics
Viewing all articles
Browse latest Browse all 3145

How to make a list of "OR" for query of unique IDs

$
0
0
Hi,I am probably considered a beginner at SQL compared to most of you!Here is code that I have that works:set @PAT_Filter=N'AND PATIENT.PAT_ExternalId like (''%123456'')'I now have a long list of PATIENT.PAT_ExternalIds and I would like to have a list of all patients in the database that match the numbers on the list exactly. No matter what I do, I can't seem to figure out the right combination of "ORs" and placement of "s and 's and ( )s to get it to work without an error message. PAT.ExternalId is string, not numeric.This does not work:set @PAT_Filter=N'AND PATIENT.PAT_ExternalId in (''123456'',''654321'')'This does not work:set @PAT_Filter=N'AND PATIENT.PAT_ExternalId = ('123456'OR '654321')Does anyone have any ideas? Thank you!Danielle

Viewing all articles
Browse latest Browse all 3145

Trending Articles