34,838
社区成员




select 产品说明=ProductDesc,产品库存数量=StoreNumber,仓库=StoreRoomID,推荐类型=CommendTypeID,产品小类=SmallTypeID,产品来源=ProductSourceID,PV值=PV,BV值=BV,产品大类=TypeID,产品描述=Description,报警数量=AlarmNumber,产品适用人群ID(对应表ProductApplyPeople)=ProductApplyPeopleID,产品形态ID(对应表ProductForm)=ProductFormID,产品重量=ProductWeight,产品颜色ID号(对应表ProductColor)=ProductColorID,产品尺寸ID(对应表ProductSize)=ProductSizeID,产地=ProductArea,单位数量=UnitNumber,小单位(对应ProductUnit表)=SmallUnitID,大单位ID(对应表ProductUnit)=BigUnitID,优惠价格积分=ActressPriceIntegral,普通价格积分=CommonPriceIntegal,会员价格=ActressPrice,市场价格=CommonPrice,成本价格=CostPrice,产品规格ID(与产品规格表ProductSpecs对应)=ProductSpecsID,产品型号=ProductCode,是否组合产品(1是,0不是)=IsTeam,产品名称=ProductName from t_product_list
insert into datadict select 't_product_list','pname','产品名称',1,1
declare @sql varchar(8000)
set @sql=''
select @sql=@sql+','+colnote+'='+cloname
from datadict where tablename='t_product_list' and conshow=1 order by consort desc
set @sql='select '+stuff(@sql,1,1,'')+' from t_product_list'
exec(@sql)
--我没看懂你的意思,把试试下面这个:
declare @sql varchar(1000)
set @sql=''
select @sql=@sql+',['+colnote+']='+cloname --这里加了[]符号,看有没有效果?
from datadict where tablename='t_product_list' and conshow=1
set @sql='select '+stuff(@sql,1,1,'')+' from t_product_list'
print @sql --加个显示动态SQL,看看什么地方出错?
exec(@sql)
declare @tn varchar(50),@b int ,@e int,@sql varchar(1000)
select @tn = 't_product_list',@b= 1,@e = 2
select @sql = isnull(@sql+',','')+colnote+'='+cloname from datadict
where tablename = @tn and consort between @b and @e order by consort
set @sql = 'select '+@sql+' from '+@tn
exec(@sql)