Showing posts with label identity. Show all posts
Showing posts with label identity. Show all posts

Tuesday, March 20, 2012

Check for username

Hello,
I have the following Table:
CREATE TABLE [dbo].[tb_User] (
[usr_id] [int] IDENTITY (1, 1) NOT NULL ,
[usg_groupID] [int] NOT NULL ,
[usr_createdBy] [int] NOT NULL ,
[usr_isActive] [int] NOT NULL ,
[usr_dateCreated] [datetime] NOT NULL ,
[usr_userName] [varchar] (25) NULL ,
[usr_password] [varchar] (50) NULL ,
[usr_firstName] [varchar] (50) NULL ,
[usr_lastName] [varchar] (50) NULL ,
[usr_eMail] [varchar] (50) NULL ,
[usr_phoneNumber] [varchar] (50) NULL ,
[usr_notes] [varchar] (512) NULL
)
I want to set up a stored procedure that will take two parameters
(@.UserName varchar(50) and @.Password varchar(50)) that I want to use to
check for the following
1. Check to see that the username exisits and that the column isActive = 1
2. If step 1 is true, then check that the @.Password Parameter is the
same for the user
3. If step 2 above is true return 1
4. If step 1 about is false (either the username does not exist, of if
it does it's not active (isActive = 0) return 0
I am going to use the Return value in my C# application to warn the user
that either the username does not exist, or it's not active or the
password is wrong.
Anything anyone can provide me with will be greatly appreciated!It would be simple as this:
e.g.
create proc usp
@.user varchar(25),
@.pass varchar(50)
as
set nocount on
if exists(select 1 from tb_User where usr_userName=@.user and usr_isActive=1
and usr_password=@.pass)
return 0
else
return 1
go
-oj
"Ed_P." <ed_p@.no-email.com> wrote in message
news:eX3GmN0CFHA.2180@.TK2MSFTNGP12.phx.gbl...
> Hello,
> I have the following Table:
> CREATE TABLE [dbo].[tb_User] (
> [usr_id] [int] IDENTITY (1, 1) NOT NULL ,
> [usg_groupID] [int] NOT NULL ,
> [usr_createdBy] [int] NOT NULL ,
> [usr_isActive] [int] NOT NULL ,
> [usr_dateCreated] [datetime] NOT NULL ,
> [usr_userName] [varchar] (25) NULL ,
> [usr_password] [varchar] (50) NULL ,
> [usr_firstName] [varchar] (50) NULL ,
> [usr_lastName] [varchar] (50) NULL ,
> [usr_eMail] [varchar] (50) NULL ,
> [usr_phoneNumber] [varchar] (50) NULL ,
> [usr_notes] [varchar] (512) NULL
> )
> I want to set up a stored procedure that will take two parameters
> (@.UserName varchar(50) and @.Password varchar(50)) that I want to use to
> check for the following
> 1. Check to see that the username exisits and that the column isActive = 1
> 2. If step 1 is true, then check that the @.Password Parameter is the same
> for the user
> 3. If step 2 above is true return 1
> 4. If step 1 about is false (either the username does not exist, of if it
> does it's not active (isActive = 0) return 0
> I am going to use the Return value in my C# application to warn the user
> that either the username does not exist, or it's not active or the
> password is wrong.
> Anything anyone can provide me with will be greatly appreciated!

Check for missing identity numbers

Is there a way to check for missing identity numbers in a Primary Key column? I have some databases that are not fully normalized and want to check on tables that might have had some records deleted. Thank you.

Do you really want to do this in SSIS? Whilst possible I think a SQL based solution would be much faster, and probably makes more sense. A quick Google will come up with plenty of script samples e.g. http://www.nigelrivett.net/FindGapsInSequence.html|||

If you just need to know the number of 'deleted' rows; you can do a simple substraction of the max identitity number minus the number of rows in the table. If you need a list of the ID's that not exists in the table; then you could use a cursor that from 1 to max identity and checks if the row exists in the table or not....anyway you may find more help in the t-sql forum that is next door Smile

Sunday, March 11, 2012

Check constraint for identity range

Hi,
When I delete subscriptions and publications and disable the replication,
the check constraint for identity range stays in subscriber for tables. Then
I have to manually drop or disable them. Is it an expected behavior or
there's something wrong in my work? How can I have them removed
automatically?
Thanks in advance,
Leila
I reported this problem to Microsoft already. From what I understand this
request was unanticipated by the design team. They expected that when you
replicate to a subscriber, the publisher subscriber relationship is forever.
They did not anticipate customers breaking replication and then using the
subscriber as a standalone database.
I did post a script here sometime ago to remove these constraints.
Hilary Cotter
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602.html
"Leila" <Leilas@.hotpop.com> wrote in message
news:ecnVFp18EHA.808@.TK2MSFTNGP10.phx.gbl...
> Hi,
> When I delete subscriptions and publications and disable the replication,
> the check constraint for identity range stays in subscriber for tables.
Then
> I have to manually drop or disable them. Is it an expected behavior or
> there's something wrong in my work? How can I have them removed
> automatically?
> Thanks in advance,
> Leila
>
|||Thanks Hilary,
Could you please post a link to your script again.
Thanks again,
Leila
"Hilary Cotter" <hilary.cotter@.gmail.com> wrote in message
news:uXYke518EHA.1392@.tk2msftngp13.phx.gbl...
>I reported this problem to Microsoft already. From what I understand this
> request was unanticipated by the design team. They expected that when you
> replicate to a subscriber, the publisher subscriber relationship is
> forever.
> They did not anticipate customers breaking replication and then using the
> subscriber as a standalone database.
> I did post a script here sometime ago to remove these constraints.
> --
> Hilary Cotter
> Looking for a SQL Server replication book?
> http://www.nwsu.com/0974973602.html
> "Leila" <Leilas@.hotpop.com> wrote in message
> news:ecnVFp18EHA.808@.TK2MSFTNGP10.phx.gbl...
> Then
>