Thursday, March 8, 2012

Code help

Hi everyone,
When I use the following talbe for my database, while adding this database a full record, it always give this error;
String or binary data would be truncated.
The statement has been terminated.
The bad thing is that I can not overcome this error.
So what did I do wrongly is the following ?

CREATE TABLE Muhasebe
(
KimlikNo int CONSTRAINT PK_Kimlik PRIMARY KEY CLUSTERED NOT NULL,
Ad nvarchar NOT NULL,
Giri?Tarih datetime CONSTRAINT CH_Tarih CHECK (Giri?Tarih > '1/1/2006' AND Giri?Tarih < '06/07/2006'),
Büt?e money NOT NULL)SELECT * FROM Muhasebe

The above error causing code;
INSERT Muhasebe VALUES(12, 'mert','3/3/2006',120.000)


you need to give the Ad column a size, if you don't specify a size 1 will be assumed

CREATE TABLE Muhasebe
(
KimlikNo int CONSTRAINT PK_Kimlik PRIMARY KEY CLUSTERED NOT NULL,
Ad nvarchar(200) NOT NULL,
Giri?Tarih datetime CONSTRAINT CH_Tarih CHECK (Giri?Tarih > '1/1/2006' AND Giri?Tarih < '06/07/2006'),
Büt?e money NOT NULL)

I gave it 200, you might need less, remember nvarchar uses 2 bytes to store 1 character

Denis the SQL Menace

http://sqlservercode.blogspot.com/

|||

Thanks very much for this.
Meanwhile, I enjoy your web blog.
Again thanks very much.

Best wishes,
Mert

No comments:

Post a Comment