提问人:Vinbeatz180 提问时间:11/2/2023 最后编辑:marc_sVinbeatz180 更新时间:11/2/2023 访问量:17
消息 8117,级别 16,状态 1,第 17 行 操作数数据类型 varchar 对于乘法运算符无效
Msg 8117, Level 16, State 1, Line 17 Operand data type varchar is invalid for multiply operator
问:
这是我的SQL代码:
DECLARE @TempTableList TABLE (ID INT IDENTITY(1,1),NAME NVARCHAR(300))
BEGIN
INSERT INTO @TempTableList (NAME) (
SELECT NAME FROM SYS.tables
WHERE NAME LIKE 'BASKRSAPMT_MTG_20%')
DECLARE @REC_ID AS INT
SET @REC_ID = 1
DECLARE @SQLQUERY AS NVARCHAR(MAX)
WHILE (@REC_ID <= (SELECT COUNT(*) FROM @TempTableList))
BEGIN
DECLARE @TblName VARCHAR (200)
SET @TblName=(SELECT NAME FROM @TempTableList WHERE ID=@REC_ID)
SET @SQLQUERY= 'UPDATE '+@TblName+' SET [MLOCN1] ='' CASE WHEN LEN(TRIM([MLOCN1])) >1 and LEN(TRIM([MLOCN1])) <5 THEN CONCAT(LEFT(TRIM([MLOCN1]), 1),REPLICATE('*', 3),
RIGHT(TRIM([MLOCN1]),1)) WHEN LEN(TRIM([MLOCN1]))>= 5 THEN CONCAT(LEFT(TRIM([MLOCN1]), 1),REPLICATE('*', LEN(TRIM([MLOCN1]))- 2),RIGHT(TRIM([MLOCN1]),1)) ELSE [MLOCN1] end'
EXECUTE(@SQLQuery)
SET @REC_ID= @REC_ID + 1
END
end
我收到此错误:
消息 8117,级别 16,状态 1,第 17 行
操作数数据类型 varchar 对于乘法运算符无效
答: 暂无答案
评论