question

kitacat avatar image
kitacat asked

In this SQL Stored Procedure, where do I enter my Variable

I manage a SQL site but know next to nothing about SQL. In the backend, I found this Stored Procedure to Unlock a User, but don't know how to execute it. There is an "Apply Code" button. I just need to know where do I put the Username I need to unlock? Say the Username is SUZY ... exactly what do I replace with SUZY before I hit APPLY? Thank you so much!! ==CODE========= USE [TestSite] GO /****** Object: StoredProcedure [dbo].[aspnet_Membership_UnlockUser] Script Date: 07/10/2017 07:55:21 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER OFF GO ALTER PROCEDURE dbo.aspnet_Membership_UnlockUser @ApplicationName nvarchar(256), @UserName nvarchar(256) AS BEGIN DECLARE @UserId uniqueidentifier SELECT @UserId = NULL SELECT @UserId = u.UserId FROM dbo.aspnet_Users u, dbo.aspnet_Applications a, dbo.aspnet_Membership m WHERE LoweredUserName = LOWER(@UserName) AND u.ApplicationId = a.ApplicationId AND LOWER(@ApplicationName) = a.LoweredApplicationName AND u.UserId = m.UserId IF ( @UserId IS NULL ) RETURN 1 UPDATE dbo.aspnet_Membership SET IsLockedOut = 0, FailedPasswordAttemptCount = 0, FailedPasswordAttemptWindowStart = CONVERT( datetime, '17540101', 112 ), FailedPasswordAnswerAttemptCount = 0, FailedPasswordAnswerAttemptWindowStart = CONVERT( datetime, '17540101', 112 ), LastLockoutDate = CONVERT( datetime, '17540101', 112 ) WHERE @UserId = UserId RETURN 0 END GO
sqlprocedure
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

DenisT avatar image
DenisT answered
Open New Query Window in SQL Server Management Studio and connect to the instance that you would like to run the stored procedure against. Change "master" database from the drop-down list to the database (TestSite) where the stored procedure had been deployed. Then run this: EXEC dbo.aspnet_Membership_UnlockUser @ApplicationName = N'YOUR APP NAME', @UserName = N'SUZY'; Replace N'YOUR APP NAME' with the appropriate application name.
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

kitacat avatar image
kitacat answered
Thank you so much for helping. I am not clear on how to do this. Here is a screenshot of where I was trying to enter it. Can I enter that code somewhere in this window then click APPLY or do I have to go to SS Management Studio? ![alt text][1] [1]: /storage/temp/4183-storedprocedure.jpg

storedprocedure.jpg (168.9 KiB)
4 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

See the "Query Analyzer" icon on the left under "Tools"? Click on that and you should get a blank window where you can enter a SQL command. Enter the query provided by @DenisT in that window, provide your app name and user name where indicated by that answer, then run the query.
1 Like 1 ·
I have never used SQL Server Web Admin. So, I would not know who to do in that tool. I was referring to SQL Server Management Studio. What version of SQL Server are you using?
0 Likes 0 ·
SQL Server Version 2005
0 Likes 0 ·
So you have SSMS installed? Just use that.
0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.