用户已经在SQL Server中退出 [英] User already exits in sql server

查看:92
本文介绍了用户已经在SQL Server中退出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

用户已经退出存储过程了吗?

当输入重复的用户名警报消息时,显示用户名已退出"吗?

User already exits in stored procedure ?

When enter duplicate username alert message is display User Name is already exits ?

推荐答案

您可以使用带有用户名条件的select查询来检查它是否返回任何内容.记录,那么您可以说您的用户名已经存在于数据库中.


或者,如果您在用户名上放置了任何唯一的包含,则在数据库中插入相同的用户名时,它将因违反唯一约束而引发错误.因此,使用该错误消息进行错误过滤后,您可以说您的用户已经存在于数据库中.
you can check it by using select query with where condition on user name if it will return any record then you can say that your user name is already exists in database.


or if you have put any unique contain on username then while inserting same username in database then it will throw error for violating unique constrain. so on that error filtering with that error message you can say that your user is already exists in database.


您是否尝试过
Have you tried google[^]

A simple search with your question gives 2,320,000 results, and many of those search results surely solve your problem.

Try something first, although you are a beginner. This is not at all appropriate Dhaval. Try something by your side first and then post your question if you get stuck''d somewhere.


IF Not Exists(SELECT fieldname FROM fieldmaster WHERE fieldname = @fieldname)
    insert into fieldmaster (fieldname, tooltip, label,labelalign, controltype, controlalign,
     [values], defaultvalues, minlength, maxlength, [required], [validation], isactive)
     values (@fieldname, @tooltip, @label, @labelalign, @controltype, @controlalign,
     @values, @defaultvalues, @minlength, @maxlength, @required, @validation, @isactive)
    END









BEGIN
    IF Exists (select id  from fieldmaster where fieldname = @fieldname)
    BEGIN
    Declare @ids as int = 0
    select @ids = id from fieldmaster where fieldname = @fieldname
    if(@id=@ids)
    BEGIN
    Update fieldmaster set fieldname = @fieldname, tooltip=@tooltip, label=@label, labelalign=@labelalign,
     controltype= @controltype, controlalign=@controlalign, [values]= @values, defaultvalues=@defaultvalues,
     minlength=@minlength, maxlength= @maxlength, [required]= @required, [validation] =@validation, isactive = @isactive where id = @id
    END
    END
    ELSE
    BEGIN
    Update fieldmaster set fieldname = @fieldname, tooltip=@tooltip, label=@label, labelalign=@labelalign,
     controltype= @controltype, controlalign=@controlalign, [values]= @values, defaultvalues=@defaultvalues,
     minlength=@minlength, maxlength= @maxlength, [required]= @required, [validation] =@validation, isactive = @isactive where id = @id
    END
    END


这篇关于用户已经在SQL Server中退出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆