可以先在SQL写一个函数:
Code
CREATE FUNCTION [dbo].[ExclusionAccount]
(
@Account nvarchar(30)
)
RETURNS bit
AS
BEGIN
DECLARE @Result bit
IF @Account IN ('administrator','admin','system','sys','sysadmin','db')
SET @Result= 1
ELSE
SET @Result = 0
RETURN @Result
END
CREATE FUNCTION [dbo].[ExclusionAccount]
(
@Account nvarchar(30)
)
RETURNS bit
AS
BEGIN
DECLARE @Result bit
IF @Account IN ('administrator','admin','system','sys','sysadmin','db')
SET @Result= 1
ELSE
SET @Result = 0
RETURN @Result
END
在用户注册或是更改帐号时,如同下面判断:
Code
DECLARE @IsEXIST bit
SELECT @IsEXIST = (SELECT[dbo].ExclusionAccount(@Account))
IF(@IsEXIST = 1)
BEGIN
RAISERROR(N'此帐号:%s是系统预定帐号!',16,1,@Account)
RETURN
END
DECLARE @IsEXIST bit
SELECT @IsEXIST = (SELECT[dbo].ExclusionAccount(@Account))
IF(@IsEXIST = 1)
BEGIN
RAISERROR(N'此帐号:%s是系统预定帐号!',16,1,@Account)
RETURN
END