Sql-server – lookup the Primary Key in SQL Server from Excel Spreadsheet

excelimportsql serversql-server-2016

Disclaimer: I'm a database novice teaching myself for a research project.

Background: I am querying an electronic medical record (EMR) system for information pertinent to my project and I do not want to store medical record numbers (just say "no" HIPAA violations!). The database is designed with Visit_ID as a Primary Key and four fields which result in a unique combination: admission date & time, length of stay, admitting physician, and room number. All other information will be based on the Visit_ID. For example, the "Medications" table starts with Visit_ID as a Foreign Key and all other information such as start date, stop date, etc.

Problem: The EMR system obviously does not know my Visit_ID. Therefore, all of my queries will have the four fields which are defined by Visit_ID in my database.

Question: Can I resolve or lookup the Visit_ID within the database from the four columns in my Excel sheet?

Example: I query the EMR for the medications the patients had in June. My query returns an Excel spreadsheet with my four fields (Admission Date & Time, Admitting Physician, Length of Stay, and Room) and all the necessary information about the medications. Can I import data from that Excel spreadsheet into my "Medications" table but have SQL Server resolve Visit_ID instead of keeping those four fields?

Best Answer

Yes, Excel can query data from a database. On the Data tab there are tools to create and maintain connections. IIRC it uses ODBC so all major database products can be referenced.