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 |
iSQL
Starting Member
6 Posts |
Posted - 2009-03-09 : 19:28:05
|
Hello everyone,I am new here and I want some help about SQL Server Field Properties.I have a GameServer which connects to my SQL Server 2005 Express Database. When a New Game Character is created ingame, the Server inserts the data into the SQL Tables. I want to restrict the data to be entered into the Database, so that only Alphabets from A to Z are used. I want to exclude all the Numbers and special characters from entering into the Table Field. Since the GameServer source code is not available, I cannot make changes in the code to add verification checks. I need to restrict the Dataentry, which will cause the Server to return an error to the Client.Please help me in this regard.Regards,iS. |
|
sodeep
Master Smack Fu Yak Hacker
7174 Posts |
Posted - 2009-03-09 : 20:30:37
|
You can use INSTEAD of Triggers for it but that can harm performance.See if you can do with Check constraints. |
 |
|
iSQL
Starting Member
6 Posts |
Posted - 2009-03-10 : 02:42:11
|
I just need to add a Check to the Insert Query. My Server only deals much with Update queries. Hence Insert Queries are very few. I don't mind the performance much in this case.Please can you give me a detailed briefing? |
 |
|
sodeep
Master Smack Fu Yak Hacker
7174 Posts |
Posted - 2009-03-10 : 08:32:51
|
[code]ALTER TABLE Tablename ADD CONSTRAINT CK_Insert CHECK(Yourfield like '%[A-Z]%')[/code] |
 |
|
iSQL
Starting Member
6 Posts |
Posted - 2009-03-12 : 13:43:30
|
Thanks for that.How do I add a check to see if the First Character of a Name is UpperCase and the remaining characters are Lowercase? |
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-03-12 : 13:59:02
|
[code]ALTER TABLE Tablename ADD CONSTRAINT CK_Insert CHECK(LEFT(Yourfield,1) COLLATE SQL_Latin1_General_CP1_CS_AS = UPPER(LEFT(Yourfield,1)) COLLATE SQL_Latin1_General_CP1_CS_ASAND SUBSTRING(Yourfield,2,LEN(Yourfield)) COLLATE SQL_Latin1_General_CP1_CS_AS = LOWER(SUBSTRING(Yourfield,2,LEN(Yourfield))) COLLATE SQL_Latin1_General_CP1_CS_AS)[/code] |
 |
|
iSQL
Starting Member
6 Posts |
Posted - 2009-03-12 : 18:37:33
|
@visakh16Thanks for that! Works perfect.@sodeepThe Alphabet only Check is not working fine. I am able not able to Insert "5432432", but If I Insert "Name1", Its getting updated in the Table. I want to avoid all the numbers. It the Name should only contain A to Z. |
 |
|
iSQL
Starting Member
6 Posts |
Posted - 2009-03-16 : 16:04:07
|
Any solution guys? |
 |
|
|
|
|
|
|