SQL varchar vs varchar(n)
时间:2021-07-01 10:21:17
帮助过:2人阅读
@f_accounts varchar
set @f_accounts=‘H6155‘
MERGE INTO t_OtherCredit
AS T
using (SELECT @f_accounts AS f_accounts)
AS S
ON (T.f_accounts
= S.f_accounts
AND Datediff(d, T.f_date,
Getdate())
= 0)
WHEN NOT MATCHED
THEN
INSERT (f_accounts,
f_date)
VALUES(
@f_accounts,
Getdate()) ;
--执行T-SQL后查询
SELECT *
FROM t_OtherCredit
WHERE Datediff(d, f_date,
Getdate())
= 0
AND f_accounts
= ‘H6154‘
无数据,然而,直接替换@f_accounts为字面量查询到正常数据
【修复】:declare @f_accounts varchar(20)
【在哪些文件修改了】: 无
【我导致的】:是
【解决Bug的时间】:2016-07-04 13:10
【教训】:sqlserver还是简单了解阶段
SQL varchar vs varchar(n)
标签: