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
 Validate Text Field

Author  Topic 

mjdulle
Starting Member

1 Post

Posted - 2013-08-05 : 22:34:11
I am building a table with the following fields

user id - char (15)
password - char (41)
full name - varchar (50)
email - varchar (50)
scout ID text

When the scout registers as a user he will enter his scout ID. I want his ID to validate against the scout ID recorded in his table record. Can text fields be validated on input?

MuMu88
Aged Yak Warrior

549 Posts

Posted - 2013-08-05 : 23:13:03
Yes, you can but Microsoft recommends avoid using text data type.
Read this: http://msdn.microsoft.com/en-us/library/ms187993.aspx

If you use where clause to compare [scout ID], you have to do use LIKE as below:
[CODE]

SELECT * from YOUR_TABLE_NAME WHERE [scout ID] LIKE 'Ten Bears';

[/CODE]
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-08-05 : 23:34:25
is scout details held in a separate table? if yes, you could add a fk constraint to validate the entered value against scout table

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-08-05 : 23:52:31
And as previous post says from SQL 2005 onwards you should be using varchar(max) instead of text as the latter is deprecated

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
   

- Advertisement -