declare @FieldName VARCHAR(50)
declare @TableName VARCHAR(50) = 'GWW_BM_T_IndustrialSource'
declare B_Cursor1 cursor for SELECT a.name FROM sys.columns a JOIN sys.types b ON b.user_type_id = a.user_type_id
WHERE a.object_id = OBJECT_ID(@TableName)
open B_Cursor1;
FETCH next from B_Cursor1 into @FieldName
WHILE @@FETCH_STATUS =0
begin
EXEC('UPDATE '+@TableName+' SET '+@FieldName+' = NULL WHERE CAST('+@FieldName+' AS VARCHAR(50)) = ''--'' ')
fetch next from B_Cursor1 into @FieldName
end
CLOSE B_Cursor1;
DEALLOCATE B_Cursor1;
SQLSERVER 更新所有字段
最新推荐文章于 2024-08-20 10:01:20 发布