M
maill01
Unregistered / Unconfirmed
GUEST, unregistred user!
declare @sql varchar(8000) <br>set @sql='SELECT W.ID,W.UserCode,W.Name,W.Sort,W.Unit' <br>select @sql=@sql+',isnull(sum(case D.Name when '''+A.Name+''' then Number end),0) ['+A.Name+']' <br>From (select distinct name from depot) as a <br>select @sql=@sql+'FROM WareStock AS K,Ware AS W,Depot AS D <br> WHERE K.WareID=W.ID and K.DepotID=D.ID <br> GROUP BY W.ID,W.UserCode,W.Name,W.Sort,W.Unit'<br><br>这段代码,写成存储过程,如何调用?