首页 > 解决方案 > 为什么 PRINT 不会产生结果

问题描述

我正在研究一个存储过程来解决项目 Euler 的问题 2,并且打印语句不会打印结果。我尝试过使用 select 但它也不起作用。我到处都放了打印语句,看看是否有任何运行。我已经在 Visual Studio 中测试了这段代码(当然是 C# 形式)并且它运行了,所以我不认为它是任何想法的代码?

USE [johnsodx]
GO
  /****** Object:  StoredProcedure [dbo].[kibonacci]    Script Date: 11/10/2020 10:16:46 AM ******/
  SET ANSI_NULLS ON
  GO
  SET QUOTED_IDENTIFIER ON
  GO
  -- =============================================
  -- Author:        <Author,,Name>
  -- Create date: <Create Date,,>
  -- Description:   <Description,,>
  -- =============================================
Create PROCEDURE Fibonacciss

AS

DECLARE @f0 INT
DECLARE @f1 INT
DECLARE @fcom INT
DECLARE @f_sum INT

SET  @f0 = 1
SET  @f1 = 1
SET  @fcom = 0
SET  @f_sum = 0

 set statistics time on --Keeps track of the time it takes to excute query
 Print @f_sum
 while @fcom <= 4000000 
 BEGIN
 set @fcom = @f0 + @f1;

  if (@fcom % 2 = 0)
  set
      @f_sum += @fcom;


   set  @f0 = @f1;
   set   @f1 = @fcom;

   Print @f_sum
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.


-- Insert statements for procedure here
   Print @f_sum
   Print @fcom
   END
    Print  @f_sum

标签: sqlsql-serverstored-procedures

解决方案


我很笨,不知道执行之间的区别:创建和运行它


推荐阅读