数据库查询和页面显示不一样的结果
小弟的存储过程:程序代码:
[color=#0000FF]setANSI_NULLS ON set QUOTED_IDENTIFIER ON go Create PROCEDURE [dbo].[BranchStatistic_GetByAll] --获取网点统计运费 @branchname varchar(50)='', @startdate varchar(50)='', @enddate varchar(50)='', @branchcode varchar(50)='', @usertype int AS SET NOCOUNT ON declare @mssql nvarchar(4000) if (@usertype=0) set @mssql='Select Branchs.BranchCode,Branchs.BranchName ,Income = ISNULL(sum(Orders.PSettleAmount),0) ,Outcome = ISNULL(sum(Orders.ISettleAmount),0) from Branchs left join Orders on Orders.StartBranchCode = Branchs.BranchCode where 1 = 1' else set @mssql='Select Branchs.BranchCode,Branchs.BranchName ,Income = ISNULL(sum(Orders.PSettleAmount),0) ,Outcome = ISNULL(sum(Orders.ISettleAmount),0) from Branchs left join Orders on Orders.StartBranchCode = Branchs.BranchCode and StartBranchCode = '''+ @branchcode+ '''where 1 = 1' if(len(@branchname) > 0) begin set @mssql=@mssql+' and Branchs.BranchName like ''%'+@branchname+'%''' end if(len(@startdate)>0) begin set @mssql=@mssql+' and Orders.CreateTime>='''+@startdate+'''' end if(len(@enddate)>0) begin set @mssql=@mssql+' and Orders.CreateTime<='''+@enddate+'''' end set @mssql=@mssql + 'Group by Branchs.BranchCode,BranchName' exec sp_executesql @mssql SET NOCOUNT OFF[/color]
SQL查询语句
程序代码:
select Branchs.BranchCode,Branchs.BranchName ,Income = ISNULL(sum(Orders.PSettleAmount),0) ,Outcome = ISNULL(sum(Orders.ISettleAmount),0) from Branchs left join Orders on Orders.StartBranchCode = Branchs.BranchCode where 1 = 1 Group by Branchs.BranchCode,BranchName查询出来的结果
当我把参数传到存储过程里面
USE [MemberDB_lg_ceshi]
GO
DECLARE @return_value int
EXEC @return_value = [dbo].[BranchStatistic_GetByAll]
@usertype = 0
SELECT 'Return Value' = @return_value
GO
执行后 跟在SQL里面查询的结果一样
但是在 网页里面只显示一条记录。。。
希望高手帮忙下!这是什么原因。。。