是这样的 我本没有用变量 直接查询是没有问题的
后来加了存储过程 加了临时表 加了变量后 就成这样了
create procedure pi(@ID int,
@PostID int output,
@Title nvarchar(100) output,
@PostContent nvarchar(1000) output,
@Time datetime output,
@UserID int output,
@UserName nvarchar(50) output,
@ReplyCount int output)
asselect @PostID=p.PostID,
@Title=p.Title,
@PostContent=p.PostContent,
@Time=p.[Time],
@UserID=p.UserID,
@UserName=p.UserName,
(select count(*) from ReplyPost where ReplyPost.PostID=p.PostID) as ReplyCount
into #tep
from PostInfo as p
where p.PostID=@ID求解决
谢谢!

解决方案 »

  1.   

    给变量赋值,为什么要into?你想干什么
      

  2.   

    赋值了也没有机会用了还赋值干什么?直接select into 就可以了
      

  3.   


    不好意思 这个忘删了 本来是有个临时表的 现在的代码是
    create procedure pi(@ID int,
    @PostID int output,
    @Title nvarchar(100) output,
    @PostContent nvarchar(1000) output,
    @Time datetime output,
    @UserID int output,
    @UserName nvarchar(50) output,
    @ReplyCount int output)
    as
    select @PostID=p.PostID,
    @Title=p.Title,
    @PostContent=p.PostContent,
    @Time=p.[Time],
    @UserID=p.UserID,
    @UserName=p.UserName,
    (select count(*) from ReplyPost where ReplyPost.PostID=p.PostID) as ReplyCount
    from PostInfo as p
    where p.PostID=@ID提示   向变量赋值的 SELECT 语句不能与数据检索操作结合使用网上说只能拆开写?