日期:2014-05-17 浏览次数:20445 次
--drop table tb1,tb2
--go
create table tb1(id int,col1 varchar(10), col2 int, col3 varchar(10))
insert into tb1
select 11 ,'A1', 10 ,'克' union all
select 11 ,'A2', 20 ,'克' union all
select 11 ,'A3', 30 ,'克' union all
select 12 ,'A1', 50 ,'克' union all
select 12 ,'A2', 60 ,'克' union all
select 12 ,'A3', 70 ,'斤' union all
select 13 ,'A3', 10 ,'斤'
create table tb2 (id int, col1 varchar(10))
insert into tb2
select 11 ,'code1' union all
select 12 ,'code2' union all
select 13 ,'code3'
go
declare @sql varchar(1000)
set @sql = ''
select @sql = @sql +