select @col_name from Customer where (@col_name)<>lTrim(rtrim(@col_name))改为:
select @col_name from Customer where len(@col_name)<>len(lTrim(rtrim(@col_name)))
select @col_name from Customer where len(@col_name)<>len(lTrim(rtrim(@col_name)))
select column_name from information_schema.columns where table_name='Customer' and data_type='varchar'
open cur_Customer
declare @col_name varchar(100)
fetch next from cur_Customer into @col_name
while @@fetch_status=0
begin
exec('select '+@col_name+' from Customer where ('+@col_name+')<>lTrim(rtrim('+@col_name+'))')
fetch next from cur_Customer into @col_name
end
close cur_Customer
deallocate cur_Customer