将存储过程应用于SQL表以分配NULL值

时间:2015-02-25 12:32:54

标签: sql-server stored-procedures null

我有一个大的SQL表,其中包含" #N / A N / A"跨越多列/行。

如何应用存储过程将所有这些值转换为NULL值。

1 个答案:

答案 0 :(得分:2)

create table ##test2
(a1 varchar(200))
insert into ##test2 values('#N/A N/A'),('abc'),('#N/A N/A')
select  * from ##test2

create proc dbo.ex1 as
begin
set nocount on

update ##test2 set a1=null where a1='#N/A N/A'
end

select * from ##test2