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.
| Author |
Topic |
|
mAdMaLuDaWg
Starting Member
42 Posts |
Posted - 2004-08-18 : 21:54:07
|
| I'm having trouble with a constraint, here is my constraint expression on TempUserDB:CONSTRAINT CK_CHECKUNIQUEUSERNAME CHECK ([dbo].[CheckUniqueUsername]([Username]) = 0)Here is my function:CREATE FUNCTION dbo.CheckUniqueUsername(@Username varchar(50))RETURNS intASBEGINDECLARE @UserCount intSelect @UserCount=count(*) from vwUserCheck where UserName=@UsernameReturn @UserCountENDAnd finally, here is my view:CREATE VIEW dbo.vwUserCheckASSELECT dbo.TempUserDB.Username, dbo.TempUserDB.EmailFROM dbo.TempUserDBUNIONSELECT dbo.UserDB.Username, dbo.UserDB.EmailFROM dbo.UserDBThe problem is that whenever I insert anything a user in the TempUserDB, the constraint somehow fails, although all tables are empty.What am I doing wrong?As always, the help is much appreciated. |
|
|
|
|
|