0

I have created a stored procedure in SQL Server to add new student record to Student table. I have grant permission to one of the roles I created that is "DBAdmins". I have also login as "DBAdmins" and run the store procedure successfully, it returns 1 row affected. But when I select * from student table, it has nothing in the table. Below is the stored procedure I created and the execute command run from DBAdmins.

I have tried run the execute command, try "INSERT INTO" command, but nothing is working. There is no result in the student table.

Store Procedure

CREATE PROCEDURE dbo.AddNewStudent
    @StudentID VARCHAR(6),
    @TempPassword VARCHAR(100),
    @Name VARCHAR(100),
    @Phone VARCHAR(20)
AS
BEGIN
    OPEN SYMMETRIC KEY PasswordEncryptionKey
    DECRYPTION BY CERTIFICATE AISServerCert;

    INSERT INTO dbo.Student (ID, SystemPwd, Name, Phone)
    VALUES (
        @StudentID, 
        EncryptByKey(Key_GUID('PasswordEncryptionKey'), @TempPassword),
        @Name, 
        @Phone
    );

    CLOSE SYMMETRIC KEY PasswordEncryptionKey;
END;
GO

Execute Command

EXEC dbo.AddNewStudent
    @StudentID = 'ST1001',
    @TempPassword = 'TP0001@1234',
    @Name = 'John Doe',
    @Phone = '012-2148759';
New contributor
Jason Low is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.