SQL Server Stored Procedure verification login instance

Source: Internet
Author: User

Note:

Stored Procedures can prevent the threat of SQL Injection Vulnerabilities and are very secure. The Stored Procedure contains input and output parameters. The input parameters include the user ID and password. The returned values indicate different results.

Alter procedure [DBO]. [logining] (@ in_id varchar (10), @ in_password varchar (10), @ out_parameter varchar (10) Output) /** @ in_id input parameter ID @ in_password input parameter password @ out_parameter outgoing parameter 0 success/1 Password error/2 Current Status unavailable or other reasons */asdeclare @ temp_password varchar (10 ); declare @ temp_status varchar (10); declare @ temp_blog varchar (10); declare @ temp_event varchar (100); declare @ temp_count int; select @ temp_count = count (*) from users where id = @ in_id; select @ temp_password = password from users where id = @ in_id; select @ temp_status = status from users where id = @ in_id; set @ temp_event = 'Log On to the system client'; -- verify that the password is correct if (@ temp_count <1) set @ out_parameter = 3; else beginif (@ temp_password = @ in_password) begin -- verify whether the status is available if (@ temp_status = 1) beginset @ out_parameter = 0; Exec writeblog @ in_id, @ temp_event, @ temp_blog output; endelsebeginset @ out_parameter = 2; endendelseset @ out_parameter = 1; End

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.