February 21, 2023 at 3:15 am
Hey folks. I need to be able to have a little box or similar pop up so a user can enter a value, that will be part of the SELECT statement. I have looked everywhere and have had no luck. Oracle has this option I believe with the &.
This works in Oracle: this will pop up a box for user to enter value
declare a number;
begin
a := &x;
end;
/
February 21, 2023 at 10:22 am
SQL Server is not a front end piece of software and will not prompt a user for an input.
If you want to get a user to pass values, you need to go and give them something else to do it in.
EXCEL with VBA code
Access
Write your own application in VB.Net/C/PowerShell etc.
Either that or you educate them on static T-SQL scripts and you tell them run this in SSMS but make sure you change the value here on line ###, but giving users SSMS and access to the DB even if it is only read access. Oh hell no, DB access like that is privileged access and should be treated as such, you never know what other queries they will run and open you up to potential data breaches.
February 21, 2023 at 10:48 am
In SSMS you could write code like a template and then press Cntl-Shft-M to fill in the values. Look at the template explorer under the view menu.
February 21, 2023 at 11:15 am
If everything about the SELECT is static other than this 'value', you may be able to create a table-valued function (link) for them.
The absence of evidence is not evidence of absence
- Martin Rees
The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
- Phil Parkin
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply