sql存储过程与sqldatasource的问题~
写了一个存储过程
ALTER PROCEDURE dbo.StoredProcedure1
AS
SELECT COUNT(*) AS Expr1 FROM BBS_Artical
SELECT COUNT(*) AS Expr2, ParentID FROM BBS_Artical GROUP BY ParentID HAVING(ParentID = 0)
SELECT COUNT(*) AS Expr3 FROM UsersInfo
SELECT TOP (1) UserName FROM UsersInfo ORDER BY CreatTime DESC
RETURN
现在想将Expr1,Expr2,Expr3还有UserName的值都返回SqlDataSource中 然后绑定在其他控件上 但是现在这个存储过程执行完毕后在SqlDataSource中只能使用Expr1这个值
怎样改造一下存储过程才能使用这四个值呢?
谢谢帮忙一下~
------解决方案--------------------这几表没联系的吗?你把没联系的数据都放在一起?
------解决方案--------------------Union是集合.
declare @UserName varchar(20)
SELECT @UserName = TOP (1) UserName FROM UsersInfo ORDER BY CreatTime
declare @Expr1 int,
@Expr2 int,
@Expr3 int
Select @Expr1 = Count(*) FROM BBS_Artical
SELECT @Expr2 = COUNT(*) FROM BBS_Artical where ParentID=0
SELECT @Expr3 = COUNT(*) FROM UsersInfo
Select @Expr1 as Expr1, @Expr2 as Expr2, 0 as ParentID, @Expr3 as Expr3, @UserName as UserName
------解决方案--------------------帮顶~~