查询在设计器中返回结果,但不作为存储过程返回

时间:2018-01-12 01:25:31

标签: sql sql-server

我遇到了一个问题,如果我创建了一个存储过程,但它没有返回结果。

如果我在Visual Studio 2017的查询构建器中运行相同的查询,则会返回正确的结果。

我的查询如下:

set.seed(1)
model_glm2 <- train(Class ~., data=GermanCredit, method='glm',
                    tuneGrid=expand.grid(parameter=c(0.001, 0.01, 0.1, 1,10,100, 1000)))
model_glm2
#Generalized Linear Model 

#1000 samples
#  61 predictor
#   2 classes: 'Bad', 'Good' 

#No pre-processing
#Resampling: Bootstrapped (25 reps) 
#Summary of sample sizes: 1000, 1000, 1000, 1000, 1000, 1000, ... 
#Resampling results across tuning parameters:

#  Accuracy   Kappa      parameter
#  0.7386384  0.3478527  0.001    
#  0.7386384  0.3478527  0.001    
#  0.7386384  0.3478527  0.001    
#  0.7386384  0.3478527  0.001    
#  0.7386384  0.3478527  0.001    
#  0.7386384  0.3478527  0.001    
#  0.7386384  0.3478527  0.001    

#Accuracy was used to select the optimal model using  the largest value.
#The final value used for the model was parameter = 0.001.

程序是:

SELECT        
    PersonDetails.FirstName, PersonDetails.MiddleName, 
    PersonDetails.LastName, PersonDetails.DOB, PersonDetails.Gender, 
    CSVToTable_1.String AS SearchedID, 
    DealerTransactions.Address, DealerTransactions.AddressSuburb, 
    DealerTransactions.IDUsed, DealerTransactions.TransactionDate, 
    DealerTransactions.TransactionType, DealerTransactions.Item, 
    DealerTransactions.ItemDescription, DealerTransactions.SerialNumber, 
    DealerTransactions.TransactionNumber, DealerTransactions.ItemAmount, 
    DealerShops.ShopName
FROM
    PersonDetails 
INNER JOIN
    dbo.CSVToTable(@LIST) AS CSVToTable_1 ON PersonDetails.Id = CSVToTable_1.String 
INNER JOIN
    DealerTransactions ON PersonDetails.Id = DealerTransactions.FK_PersonDetails 
INNER JOIN
    DealerShops ON DealerTransactions.FK_ShopID = DealerShops.Id

CSV功能

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

ALTER PROCEDURE [dbo].[SelectQuery_AllTransactionsByPersonPK]
    (@LIST VARCHAR)
AS
    SET NOCOUNT ON;

    SELECT        
        PersonDetails.FirstName, PersonDetails.MiddleName, 
        PersonDetails.LastName, PersonDetails.DOB, PersonDetails.Gender, 
        CSVToTable_1.String AS SearchedID, 
        DealerTransactions.Address, DealerTransactions.AddressSuburb, 
        DealerTransactions.IDUsed, DealerTransactions.TransactionDate, 
        DealerTransactions.TransactionType, DealerTransactions.Item, 
        DealerTransactions.ItemDescription, DealerTransactions.SerialNumber, 
        DealerTransactions.TransactionNumber, DealerTransactions.ItemAmount, 
        DealerShops.ShopName
    FROM
        PersonDetails 
    INNER JOIN
        dbo.CSVToTable(@LIST) AS CSVToTable_1 ON PersonDetails.Id = CAST(CSVToTable_1.String AS int) 
    INNER JOIN
        DealerTransactions ON PersonDetails.Id = DealerTransactions.FK_PersonDetails 
    INNER JOIN
        DealerShops ON DealerTransactions.FK_ShopID = DealerShops.Id

1 个答案:

答案 0 :(得分:2)

将长度设置为@LIST varchar,例如varchar(max)varchar(50)

示例

Declare @LIST varchar
Set @LIST = 'ABC'
Select @LIST

<强>返回

A