Reputation: 1552
This is my sql query
update employee
set StaticIp='(59.90.187.91),( 117.218.1.147)'
where EmpId=1001
Error msg:Msg 8152, Level 16, State 14, Line 1 String or binary data would be truncated. The statement has been terminated.
Upvotes: 0
Views: 96
Reputation: 20509
This means that the value you want to save in that column will not fit and will be truncated.
There is no way around this except if you increase the size of the column.
You can see the size of your column by running:
sp_columns @table_name = 'employee', @column_name = 'StaticIp'
In order to change the size of your column you need to run this command:
ALTER TABLE employee
ALTER COLUMN StaticIp NVARCHAR(MAX)
Upvotes: 1
Reputation: 36681
Storing Comma separated values in a column is bad practice.
You're getting this error of String or binary data would be truncated because StaticIP column's length is less than what you're trying to update with.
Resolution: Increase the length of StaticIP column. like StaticIP nvarchar(255)
Upvotes: 0
Reputation: 1498
This message occures when you try to insert the length data more than the database column size run the following query.
sp_help employee
check the length of staticip column , it must be less than you are entering.
Upvotes: 0