Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Stored prodedure help: Uinque varchar field

Author  Topic 

weitzhandler
Yak Posting Veteran

64 Posts

Posted - 2008-12-21 : 01:37:06
I want to have a varchar field in the rable that doesn't allow duplicates (in this field, after trim).

is it possible to set it up in the table itself?

if no how do i create a sproc that check whther the given parameter exits in that field and rejects the inesrt action?

thank you!

Shimi

nathans
Aged Yak Warrior

938 Posts

Posted - 2008-12-21 : 01:44:38
You can create a unique index or constraint to enforce the uniqueness at the schema level. Its also a good idea to check prior to inserting to inform user, "This username has already been taken" for example.

Nathan Skerl
Go to Top of Page
   

- Advertisement -