BIT SQL is assuming that ANY numeric value is TRUE while an empty string or 0 is FALSE The best way to handle this is through filtering in your code, i.e. : DECLARE @b BIT DECLARE @v char(4) = '1234' SET @b = (CASE WHEN @v = '1' THEN 1 ELSE 0 END) SELECT @b Varchar SQL doesn't consider variables as mission-critical as tables. The overflow error on tables can be disabled as well by using the SET ANSI WARNINGS OFF command I think the designers also assumed that if you are declaring a variable with a length, you will handle checking the length of that variable yourself.
Other reasons could include: You are setting the length of the variable (it's not automatic for the most part) You are specifying the input Ergo, you should know if your input will possibly overflow, and you will check for it if necessary This is different for a string than an int since a string can still be useful when truncated, while truncation fundamentally changes the nature and value of a number The recommended procedure is similar to that for bit: DECLARE @v varchar(10) DECLARE @str varchar(25) = 'This is a longer string' IF LEN(@str).
BIT SQL is assuming that ANY numeric value is 'TRUE', while an empty string or 0 is 'FALSE'. The best way to handle this is through filtering in your code, i.e. : DECLARE @b BIT DECLARE @v char(4) = '1234' SET @b = (CASE WHEN @v = '1' THEN 1 ELSE 0 END) SELECT @b Varchar SQL doesn't consider @variables as mission-critical as tables.
The overflow error on tables can be disabled as well by using the SET ANSI WARNINGS OFF command. I think the designers also assumed that if you are declaring a variable with a length, you will handle checking the length of that variable yourself. Other reasons could include: You are setting the length of the variable (it's not automatic for the most part) You are specifying the input Ergo, you should know if your input will possibly overflow, and you will check for it if necessary This is different for a string than an int since a string can still be useful when truncated, while truncation fundamentally changes the nature and value of a number.
The recommended procedure is similar to that for bit: DECLARE @v varchar(10) DECLARE @str varchar(25) = 'This is a longer string' IF LEN(@str).
Bit is true for any numeric value. I still believe it is a bad design decision which is quite error prone. BCP for example will also quietly pump data in a bit column.
Good point about SET ANSI WARNINGS OFF I just wish variables would follow this setting as well – Filip De Vos Aug 11 at 14:52 The varchar variables are especially tricky when concatenating strings in dynamic sql for example. (I know, less an issue with varchar(max)) – Filip De Vos Aug 11 at 14:53 @Filip - bit also responds to the strings TRUE and FALSE – JNK Aug 11 at 14:54 1 @filip - all the more reason to validate your inputs – JNK Aug 11 at 14:54 I put check constraints on all bit columns for now. – Filip De Vos Aug 11 at 14:56.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.