Check Constraint for varchar length in a Password field

I'm having an issue with a field that I want to set a constraint on. I have a 'Password' field that I want to set a constraint of 8 characters or greater on. Using the Sql Server Mgt Studio I choose the check constraint button what is the code that I should use?
corporateKeenanAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Om PrakashCommented:
create table Table1t
(
Mycolumn varchar(12) check (len(Mycolumn) >= 8)
)

--This will give you error... as the length is 6 chars.
insert into Table1t values ('12abcd')

--Alter statmement to set the constraint.

alter table Table1t add constraint Mycolumn check (len(Mycolumn ) >= 8)
0
Raja Jegan RSQL Server DBA & Architect, EE Solution GuideCommented:
Though above solution would work right for you, request you to do the validation from the front end application since that would be more efficient compared to the check constraint done at the database..

CHECK constraint at database level will throw an exception to your front end application which will break your application if not handled properly..
0
corporateKeenanAuthor Commented:
Unfortunately the suggestions didn't work. I not sure if you read that I was using the SQL SERVER MANAGEMENT STUDIO's "Add Constraint" button. It would not allow the code of Password check (len(Password) >=8) it kicked back errors.
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

Raja Jegan RSQL Server DBA & Architect, EE Solution GuideCommented:
try running this ALTER syntax which might help:

ALTER TABLE ur_table
ADD CONSTRAINT password_check CHECK (len(rtrim(password)) >= 8 );
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
corporateKeenanAuthor Commented:
Still no resolution via the Management Studio. I will be closing this thread, thanks anyways.
0
Raja Jegan RSQL Server DBA & Architect, EE Solution GuideCommented:
>> Still no resolution via the Management Studio.

Have you tried the TSQL command as in my comment# 29098925
And SSMS has some bugs like this and request you to do everything in TSQL to get tasks done..
0
corporateKeenanAuthor Commented:
I haven't tried the TSQL command yet I had decided to move on to some other tasks that needed to be developed on the database. I will revisit again this weekend because the development team needs the DB by Monday.
0
Raja Jegan RSQL Server DBA & Architect, EE Solution GuideCommented:
Ok.. Try that TSQL approach and let me know your comments..
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2005

From novice to tech pro — start learning today.