Question

I have created a stored procedure that returns the number of points scored by a player based on their surname - as I test, I don't keep records of this sort of thing.

CREATE PROCEDURE getpoints @surname nvarchar(30)
AS
SELECT points
FROM videogames.cod
WHERE surname = @surname
GO

This shows the points for the user darthvader :

Execute getpoints @surname = 'darthvader'

What changes do I need to make to the code so that I don't have to specify a username? When the procedure executes I want it to request a username and once that is entered the points are returned?

Was it helpful?

Solution

The short answer is ce n'est pas possible! — Fundamentally, you can't.

The longer answer is that SQL Server has no way to prompt read from a keyboard or mouse. It's a data repository and access tool. For UI, you need to use something else. You can write an app to do what you want. Another possibility might be to use the facilities offered by SQL Server Reporting Services to execute your stored procedure.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top