Eu quero inserir uma linha de dados na minha tabela como name: DSKWOR00 , mas recebo este erro:
String ou dados binários seriam truncados.
então eu desliguei ANSI_WARNINGS e inseri a linha, mas o resultado não foi que meus valores
aqui está meu T-SQL:
1 - Criar minha tabela:
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 - Inserir em uma linha em Minha Tabela:
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 -O erro se eu inserir com 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 -Então, para corrigir o erro, fiz isso:
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 - Finalmente , minha linha será inserida, mas não é o valor que inseri na tabela!
---- 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