dcsimg
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: SQL
Expertise: Beginner
Feb 22, 2018

WEBINAR:

On-Demand

Building the Right Environment to Support AI, Machine Learning and Deep Learning


Allow SQL Server to Silently Truncate Data

SQL Server usually presents an error on an attempt to insert more data into a field than it can hold. It typically throws an error message similar to the following:

Msg 8152, Level 16, State 14, Line 15
 String or binary data would be truncated.
 The statement has been terminated.

To prevent this (when needed, of course), you have two options:

Turn ANSI_WARNINGS off
    SET ANSI_WARNINGS {ON|OFF}

Pass through a variable

declare @testString varchar(5)
    set @testString = 'This is a long string'
    print @testString
Hannes du Preez
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date