Field prompts for SQL loaded into Excel

sricc

New Member
Joined
Nov 21, 2014
Messages
12
I created a SQL query with MS SSMS and loaded it in Excel. The query works great except that I have to change two conditions in the WHERE statement: DED_CODE that could be one of five different four-char entries and a date field (CHECK_DATE) that will be different each time I run it. I want to set parameters that will prompt for the values. Alternatively, I would like to have the query accept the values of two entry cells in the workbook. I am also a moderate vba user. I am having difficulty finding help on the web, likely because I am asking the wrong questions. Any help will be greatly appreciated. Using Office 365.

SELECT
a.PROCESS_LEVEL AS PL,
b.NAME AS PROPERTY,
a.EMPLOYEE,
a.LAST_NAME + ', ' + a.FIRST_NAME + ' ' + a.MIDDLE_INIT AS 'FULL NAME',
a.FICA_NBR AS SSAN,
a.UNION_CODE,
e.DESCRIPTION AS STATUS,
c.CHECK_DATE,
c.DED_CODE,
c.DED_AMT
FROM
STG_LawsonHR.LAW10DB.DBHREMP a
INNER JOIN
STG_LawsonHR.LAW10DB.DBHRPRS b
ON
a.PROCESS_LEVEL = b.PROCESS_LEVEL
INNER JOIN
STG_LawsonHR.LAW10DB.DBPRPYD c
ON
a.EMPLOYEE = c.EMPLOYEE
AND a.PROCESS_LEVEL = c.PROCESS_LEVEL
AND a.COMPANY = c.COMPANY
INNER JOIN
STG_LawsonHR.LAW10DB.DBPREDM d
ON
a.COMPANY = d.COMPANY
AND a.EMPLOYEE = d.EMPLOYEE
AND c.DED_CODE = d.DED_CODE
INNER JOIN
STG_LawsonHR.LAW10DB.DBHREMS e
ON
a.COMPANY = e.COMPANY
AND a.EMP_STATUS = e.EMP_STATUS
WHERE
--a.PROCESS_LEVEL IN ('002', '015')
c.DED_CODE = 'UDBT'
AND c.DED_AMT > 1
AND c.CHECK_DATE = '2022-03-10'
AND d.END_DATE = '0001-01-01'
ORDER BY
a.PROCESS_LEVEL,
a.LAST_NAME,
a.FIRST_NAME
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.

Forum statistics

Threads
1,214,987
Messages
6,122,614
Members
449,091
Latest member
gaurav_7829

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top