Getting Started with Adobe After Effects - Part 6: Motion Blur

Upload Image Close it
Select File

Browse by Tags · View All
sql_server 217
t-sql 211
tsql 116
sqlserver 96
BRH 78
#SQLServer 66
#TSQL 56
SQL Server 34
function 11

Archive · View All
August 2007 17
August 2010 8
June 2012 7
June 2011 7
November 2007 7
August 2012 6
May 2012 6
November 2011 6
August 2011 6
October 2011 6

Madhivanan's TSQL Blog

Column length and Data length

Dec 4 2007 6:34AM by Madhivanan   

When you use character datatypes(char,varchar,nchar,etc),always make sure that column has enough length to have data. Otherwise sometimes you would get errors and sometimes you wont. Consider the following example

Declare @t table(i int, test_col varchar(2))
Insert into @t 
select 1,'test'
Select i,test_col from @t 

Well. You get the error

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

Because the column length of test_col is not enough to have the value 'test' But only when you insert data to a table, you get this error. In other cases you dont

Declare @v varchar(2)
set @v='test'select @v

Now there is no error but the value is truncated and only first two characters are assigned to the variable. The same case is applied when you use a stored procedure with input parameter

create procedure test(@test_param varchar(2))as
Select @test_param
EXEC test1 'test'
drop procedure test

Now see what happens when you dont specify the length

Declare @v varchar
set @v='test'
select @v

By default the length is 1 Consider another example

Select cast('This has more than thirty characters' as varchar)

The result is This has more than thirty char When you cast a literal to character type without specifying the length, by default it is 30. So you need to specify the enough column length when you use character datatypes

Tags: t-sql, sql_server, column_length, data_length,

2 · 40% · 13039


Your Comment

Sign Up or Login to post a comment.

"Column length and Data length" rated 5 out of 5 by 1 readers
Column length and Data length , 5.0 out of 5 based on 1 ratings
    Copyright © Rivera Informatic Private Ltd Contact us      Privacy Policy      Terms of use      Report Abuse      Advertising      [ZULU1097]