如果存储过程的用户名为空,则阻止登录



在数据库userrecord中,我有一个登录名为空的用户,并且该用户仅使用密码即可登录其帐户。如何防止这种情况发生?请指教?

这将起作用:

IF NULLIF(@LoginName, '') IS NULL ...

IF(@LoginName IS NULL OR @LoginName = '') ...

将其放在您的登录 SP 中

if len(isnull(@LoginName,'')) = 0 -- or <@MinLoginNameLength if you wish
Begin
--      Select 'naughty, get a username'
RAISERROR('%s',16,1,'cheaters never prosper.')
end

> 100% 工作

if(@LoginName IS NOT NULL OR @LoginName <> '')
{
-- Your Statement or your Query
} 

请尝试此查询

最新更新