怎样将sql数据库字段中的NULL都替换为空
1个回答
展开全部
大概想法是通过利用sys.columns这个系统表,然后组合语句之后执行。
declare @cmd varchar(MAX)declare @column varchar(MAX)declare @index intwhile 1 = 1 select top 1 @column = name, @index = column_id from sys.columns where column_id > @index and object_name(object_id) = 'Table_name'if @column is null breakselect @com = 'update Table_name set ' + @column + ' = '''' where ' + @column + ' is null'exec(@cmd)end
declare @cmd varchar(MAX)declare @column varchar(MAX)declare @index intwhile 1 = 1 select top 1 @column = name, @index = column_id from sys.columns where column_id > @index and object_name(object_id) = 'Table_name'if @column is null breakselect @com = 'update Table_name set ' + @column + ' = '''' where ' + @column + ' is null'exec(@cmd)end
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询