我想在我的表中插入一个数据行,名称为:DSKWOR00,但出现此错误:
字符串或二进制数据将被截断。
所以我关闭了 ANSI_WARNINGS 并插入了行但结果不是我的值
这是我的 T-SQL :
1 - 创建我的表:
CREATE TABLE [dbo].[DSKWOR00]( [DSW_ID] [nvarchar](10) NULL, [DSW_YY] [float] NOT NULL, [DSW_MM] [float] NOT NULL, [DSW_LISTNO] [nvarchar](12) NULL, [DSW_ID1] [nvarchar](8) NULL, [DSW_FNAME] [nvarchar](60) NULL, [DSW_LNAME] [nvarchar](60) NULL, [DSW_DNAME] [nvarchar](60) NULL, [DSW_IDNO] [nvarchar](15) NULL, [DSW_IDPLC] [nvarchar](30) NULL, [DSW_IDATE] [nvarchar](8) NULL, [DSW_BDATE] [nvarchar](8) NULL, [DSW_SEX] [nvarchar](3) NULL, [DSW_NAT] [nvarchar](10) NULL, [DSW_OCP] [nvarchar](50) NULL, [DSW_SDATE] [nvarchar](8) NULL, [DSW_EDATE] [nvarchar](8) NULL, [DSW_DD] [float] NULL, [DSW_ROOZ] [float] NULL, [DSW_MAH] [float] NULL, [DSW_MAZ] [float] NULL, [DSW_MASH] [float] NULL, [DSW_TOTL] [float] NULL, [DSW_BIME] [float] NULL, [DSW_PRATE] [float] NULL, [DSW_JOB] [nvarchar](6) NULL, [PER_NATCOD] [nvarchar](10) NOT NULL, CONSTRAINT [PK_DSKWOR00] PRIMARY KEY CLUSTERED( [DSW_YY] ASC, [DSW_MM] ASC, [PER_NATCOD] Asc ) ON [PRIMARY]) ON [PRIMARY]
2 - 在我的表中插入一行:
INSERT INTO dbo.DSKWOR00
(DSW_ID,DSW_YY,DSW_MM,DSW_LISTNO,DSW_ID1,DSW_FNAME,DSW_LNAME,DSW_DNAME,DSW_IDNO,DSW_IDPLC,DSW_IDATE,DSW_BDATE,DSW_SEX,DSW_NAT,DSW_OCP,DSW_SDATE,DSW_EDATE,DSW_DD,DSW_ROOZ,DSW_MAH,DSW_MAZ,DSW_MASH,DSW_TOTL,DSW_BIME,DSW_PRATE,DSW_JOB,PER_NATCOD)
VALUES
('6773790024',1401,1,1,'80079349','¤ç¬ üóä','ö‘þõþîž','‘®¤þóä','1011','¢¥þ','0','¢¤õ','ü÷¤þ',' ñõ‘ä ¤þ¢õ',0,0,'0','0','0','0','0','0','0','0',0,'OZ0509','4430928460')
3 - 如果我使用 ANSI_WARNINGS ON 插入错误:
Msg 8152, Level 16, State 30, Line 3
String or binary data would be truncated.
--Note: My insert is correct I don't know why I'm seeing this error
4 - 所以为了修复错误,我这样做了:
SET ANSI_WARNINGS OFF
INSERT INTO dbo.DSKWOR00
(DSW_ID,DSW_YY,DSW_MM,DSW_LISTNO,DSW_ID1,DSW_FNAME,DSW_LNAME,DSW_DNAME,DSW_IDNO,DSW_IDPLC,DSW_IDATE,DSW_BDATE,DSW_SEX,DSW_NAT,DSW_OCP,DSW_SDATE,DSW_EDATE,DSW_DD,DSW_ROOZ,DSW_MAH,DSW_MAZ,DSW_MASH,DSW_TOTL,DSW_BIME,DSW_PRATE,DSW_JOB,PER_NATCOD)
VALUES
('6773790024',1401,1,1,'80079349','¤ç¬ üóä','ö‘þõþîž','‘®¤þóä','1011','¢¥þ','0','¢¤õ','ü÷¤þ',' ñõ‘ä ¤þ¢õ',0,0,'0','0','0','0','0','0','0','0',0,'OZ0509','4430928460')
SET ANSI_WARNINGS ON
5 -最后我的行将插入,但它不是我插入表中的值!
---- My Values in Inser : ('6773790034',1401,1,1,'80069349','¤ç¬ üóä','ö‘þõþîž','‘®¤þóä','1011','¢¥þ','0','¢¤õ','ü÷¤þ',' ñõ‘ä ¤þ¢õ',0,0,'0','0','0','0','0','0','0','0',0,'OZ0509','4430928444')
---- What did Insert : 6773790034 1401 1 1 80069349 ¤ç¬? ü?? ?‘???î? ‘®¤??? 1011 ¢¥? 0 ¢¤? ü÷? ??‘? ¤?¢? 0 0 0 0 0 0 0 0 0 0 0 OZ0509 4430928444