
create proc [dbo].[scanstore04](@工程号 varchar (20))
as
begin
declare @sql varchar (4000)
set @sql=N'SELECT barcode1,cast(sl as int)as sl, COUNT(stationName) AS zysl, stationName, zc, bzl, cl, ys, cc, gch, tdh, bh
FROM dbo.ScanData
WHERE 1=1
GROUP BY barcode1,stationName, sl, zc, bzl, cl, ys, cc, gch, tdh, bh '
if @工程号 <>''
set @[email protected]+' and [email protected]+''''
exec(@sql)
end
用Report Builder 2.0 做报表时,所选字段不出来,如果,把COUNT(stationNAME) GROUP BY ……去掉后,就能出字段。
------解决方案--------------------
在存储过程的第一个begin后添加下面两句试试
SET NOCOUNT ON
SET FMTONLY OFF
create proc [dbo].[scanstore04](@工程号 varchar (20))
as
begin
SET NOCOUNT ON
SET FMTONLY OFF
declare @sql varchar (4000)
set @sql=N'SELECT barcode1,cast(sl as int)as sl, COUNT(stationName) AS zysl, stationName, zc, bzl, cl, ys, cc, gch, tdh, bh
FROM dbo.ScanData
WHERE 1=1
GROUP BY barcode1,stationName, sl, zc, bzl, cl, ys, cc, gch, tdh, bh '
if @工程号 <>''
set @[email protected]+' and [email protected]+''''
exec(@sql)
end