hello, i am creating a user login system. When people register for the site I need a way for sql to check weather or not their is a duplicate username already in the databse. Currently, I am going through the whole member profile table searching for a duplicate name. Is there a better way to do this?i am not sure how u r performing the check and what is bothering u. however, u can create a unique index on that field and fire the insert without any check. a duplicate value will produce an error.|||Currently, I am going through the whole member profile table searching for a duplicate name. Is there a better way to do this?
If for some strange reason the unique index (actually this should be the primary key) is not an option for you, why do you "go through the whole table"?.
A simple
SELECT couint(*) from user_profile WHERE username = 'input_value';
will also tell you if there is another row with that username.|||hello, i am creating a user login system. When people register for the site I need a way for sql to check weather or not their is a duplicate username already in the databse. Currently, I am going through the whole member profile table searching for a duplicate name. Is there a better way to do this?
SELECT username, count(*)
FROM tblLogins
GROUP BY username
HAVING COUNT(*) > 1|||INSERT INTO Table(Collist) SELECT values
SELECT @.error = @.@.ERROR
IF @.@.ERROR <> 0
BEGIN
Error Handling|||hmmmm..so which way is the fastest and most efficient?|||I'd say the most efficient would be the unique index (or primary key) option, because, with correct error handling, not only can you prevent the problem from occurring, you can also provide a meaningful error message to users.sql
Showing posts with label duplicate. Show all posts
Showing posts with label duplicate. Show all posts
Wednesday, March 28, 2012
Wednesday, March 7, 2012
How do I export/import/copy Diagrams?
Is there a way to copy all the diagrams from one database to a duplicate
database?
Thank you.
Scotthttp://support.microsoft.com/default.aspx?scid=kb;en-us;320125
--
David Portas
SQL Server MVP
--
"Scott Yu" <ScottYu@.discussions.microsoft.com> wrote in message
news:30932B9B-277C-4CF0-9060-A69D8DB86D77@.microsoft.com...
> Is there a way to copy all the diagrams from one database to a duplicate
> database?
> Thank you.
> Scott|||Thank you very much. It worked.
"David Portas" wrote:
> http://support.microsoft.com/default.aspx?scid=kb;en-us;320125
> --
> David Portas
> SQL Server MVP
> --
> "Scott Yu" <ScottYu@.discussions.microsoft.com> wrote in message
> news:30932B9B-277C-4CF0-9060-A69D8DB86D77@.microsoft.com...
> > Is there a way to copy all the diagrams from one database to a duplicate
> > database?
> > Thank you.
> >
> > Scott
>
>
database?
Thank you.
Scotthttp://support.microsoft.com/default.aspx?scid=kb;en-us;320125
--
David Portas
SQL Server MVP
--
"Scott Yu" <ScottYu@.discussions.microsoft.com> wrote in message
news:30932B9B-277C-4CF0-9060-A69D8DB86D77@.microsoft.com...
> Is there a way to copy all the diagrams from one database to a duplicate
> database?
> Thank you.
> Scott|||Thank you very much. It worked.
"David Portas" wrote:
> http://support.microsoft.com/default.aspx?scid=kb;en-us;320125
> --
> David Portas
> SQL Server MVP
> --
> "Scott Yu" <ScottYu@.discussions.microsoft.com> wrote in message
> news:30932B9B-277C-4CF0-9060-A69D8DB86D77@.microsoft.com...
> > Is there a way to copy all the diagrams from one database to a duplicate
> > database?
> > Thank you.
> >
> > Scott
>
>
Subscribe to:
Posts (Atom)