我需要使用convert binary函数更新列,但它会抛出错误。
这是我的疑问:
update DocumentOnline
set FileData = CONVERT(VARBINARY(max), FileData, 0x255044462D312E340A25E2E3CFD30A322030206F626A0A3C3C2F4C656E6774682034392F46696C7465722F466C6174654465636F64653E3E73747265616D0A789C2BE4720AE1323653B03030530849E1720DE10AE42A54305430004208999CABA01F9166A8E092AF10C80500EAA209F20A656E6473747265616D0A656E646F626A0A342030206F626A0A3C3C2F5265736F75726365733C3C2F584F626A6563743C3C2F586631203120)
where ClientId = '54528' and EndDate = '201607'
这是错误:
参数数据类型varbinary(max)对转换函数的参数3无效。
我是SQL的初学者 - 我缺少什么?
答案 0 :(得分:0)
您使用了错误的CONVERT语法
https://msdn.microsoft.com/en-in/library/ms187928.aspx
-- Syntax for CONVERT:
CONVERT ( data_type [ ( length ) ] , expression [ , style ] )
尝试使用此
update DocumentOnline
set FileData = CONVERT(VARBINARY(max), 0x255044462D312E340A25E2E3CFD30A322030206F626A0A3C3C2F4C656E6774682034392F46696C7465722F466C6174654465636F64653E3E73747265616D0A789C2BE4720AE1323653B03030530849E1720DE10AE42A54305430004208999CABA01F9166A8E092AF10C80500EAA209F20A656E6473747265616D0A656E646F626A0A342030206F626A0A3C3C2F5265736F75726365733C3C2F584F626A6563743C3C2F586631203120)
where ClientId = '54528' and EndDate = '201607'
答案 1 :(得分:0)
如果FileData
的数据类型为VARBINARY(MAX)
,请使用:
update DocumentOnline
set FileData = 0x255044462D312E340A25E2E3CFD30A322030206F626A0A3C3C2F4C656E6774682034392F46696C7465722F466C6174654465636F64653E3E73747265616D0A789C2BE4720AE1323653B03030530849E1720DE10AE42A54305430004208999CABA01F9166A8E092AF10C80500EAA209F20A656E6473747265616D0A656E646F626A0A342030206F626A0A3C3C2F5265736F75726365733C3C2F584F626A6563743C3C2F586631203120
where ClientId = '54528' and EndDate = '201607'