M
M
Michael Vasyukov2017-11-29 18:53:24
SQL
Michael Vasyukov, 2017-11-29 18:53:24

Error inserting data into ms sql table?

Greetings dear forum users!
Please help me to solve this problem:
There is a filled table (dbo.Imp) with fields:
[StaffID] [varchar](50) NULL,
[Position Name] [varchar](50) NULL,
[Position Description] [varchar](50 ) NULL,
[Pay Period] [varchar](50) NULL,
[Pay Rate] [varchar](50) NULL.
Data in a table like this:
StaffID | Position Name | Position Description | Pay Period | Pay Rate
1 | text1 | text | text | 0.00
2 | text | text213 | Text43 | 1.42
etc.
Now I'm using this query (look just below), copying the fields from the dbo.Imp table and inserting them into the dbo.Position table:
Fields in dbo.Position:
[PositionId] [smallint] NOT NULL,
[PositionName] [varchar](50) NOT NULL,
[PositionDescription] [varchar](1000) NULL,
[PayPeriod] [varchar](10) NOT NULL,
[Payrate] [decimal](10, 2) NOT NULL,
The query itself:

insert into dbo.Position(PositionId,PositionName, PositionDescription, Payrate, PayPeriod)
  select StaffId, [Position Name], [Position Description], [Pay Rate], [Pay Period]
  from dbo.Imp

Error executing request:
Msg 8152, Level 16, State 14, Line 2
Character or binary data may have been truncated.
This instruction has been aborted.
PS Help please, I can not cope with this problem! Thanks!!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Holub, 2017-11-29
@programmer_developer

You have data loss in two fields
https://social.technet.microsoft.com/Forums/ru-RU/...
https://stackoverflow.com/questions/16172259/msg-8...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question