Today, I occasionally want to rewrite the previously written trigger and find some problems.
For example, the followingCode:
Declare...
...
@ Devicetype_ori int,
@ Productor_ori varchar,
@ Version_ori varchar,
@ Beginruntime_ori datetime,
@ Devicemodel_ori varchar;
I am worried about what the length will be if varchar does not define it accurately. I checked the varchar description.
Found
(From
Http://bbs.csdn.net/topics/60020321
An answer
)
Varchar [(n)]
Variable-length and non-UNICODE character data with a length of n Bytes. N must be a value between 1 and 8,000. The storage size is the actual length of the input data bytes, rather than n Bytes. The length of the input data can be zero. The synonym for varchar in the SQL-92 is Char varying or character varying.
When declaring varchar type variables, you can leave the length unspecified, but there may be problems.
E. g:
Declare @ AA varchar
Set @ AA = 'asdafdadfs'
Print (@ aa)
-- Result:
A
So the trigger does not report an error, but it will not achieve the purpose we want...
Be careful...