I need to create a stored procedure in SQL Server using the Dbeaver software and I am wondering if you have any experience with creating one with this software since I am using Mac and I am not able to install SQL Server Management Studio.
The case is that I will need to update the field for one user across all the courses assigned to that user (about 20).
It will be something like this :
UPDATE tablename
SET date = '2018-03-15'
WHERE UserID = 1234 AND ProgramID = 1234;
It is updating the date fine.
From this point, my question is about would it be better to use UPDATE
or something else since they just need to view the report for this data inside of UI? How would you start the script for this procedure and what would you use? Thanks
From your conclusive question I suppose you want the syntax to create a procedure which you can learn from so many sites available with great content. To create procedure for this specific activity your procedure will look something like this. You can dynamically add date
, user's Id
and program's Id
, if you want to take the report for some other date depending on your needs. Hope this helps.
CREATE OR REPLACE PROCEDURE updatedate(@dateupdate datetime, @ProgramID INT, @UserID INT)
AS
BEGIN
UPDATE tablename
SET date = @dateupdate
WHERE UserID = @UserID AND ProgramID = @ProgramID;
END;
To execute your procedure just replace the variables with the values you want in below query.
updatedate(@dateupdate, @ProgramID, @UserID)