错误SQL70001:在此上下文中无法识别此语句

时间:2014-05-10 10:22:57

标签: sql sql-server tsql stored-procedures

我在asp.net应用程序中存储过程如下:

CREATE PROCEDURE [dbo].[step2-e]
    @PI varchar(50),
    @Balance int output ,
    @Shipment_status varchar(50) output,
    @ETA varchar(50) output,
    @Forwarder varchar(50) output,
    @Transit_time Time output,
    @Shipping_date date output,
    @Shipping_method varchar(50) output,
    @Clearance_location varchar(50) output,
    @Advance_payment varchar(50) output 
    @Balance_t varchar(50) output,
    @Loading_date date output 
    @Balance_d date output
AS
Begin
   select 
       @Advance_payment = [advance_payment] @Balance = [Balance], 
       @Shipment_status = [Shipment_status],
       @ETA = [Eta], @Forwarder = [Forwarder], 
       @Transit_time = [Transit_time], @Shipping_date = [Shipping_date],
       @Shipping_method = [Shipping_method], 
       @Clearance_location = [Clearance_location],   
       @Balance_d = [Balance_due_d], 
       @Balance_t = [Balance_due_t], 
       @Loading_date = [Loading_date]  
   from 
       Inbound 
   where 
       [Pi1] =  @PI
End
GO

Select convert(date, [dbo].[step2-e] ,3);
GO

但是我在选择上的Go word后收到错误消息: -

  

错误SQL70001:在此上下文中无法识别此语句

好的我认为使用Go字有问题 当我搜索我发现解决方案但在asp.net网站上没有asp.net应用程序。 我找到了解决方案here,但我无法在asp.net应用程序中找到脚本文件。 我可以在asp.net网站上找到它。我该怎么办?

3 个答案:

答案 0 :(得分:51)

此错误是由于Build Action在Properties中设置为Build。将它设置为无,它应该工作正常。 find

答案 1 :(得分:3)

发布时,SELECT的前两个元素之间缺少逗号:

select 
    @Advance_payment = [advance_payment] @Balance = [Balance], 
                                       ^^^^
                                        | 
                                      here there should be a comma!

所以试试这个:

select 
   @Advance_payment = [advance_payment],
   @Balance = [Balance], 
   ..... (rest of your statement) ....

答案 2 :(得分:1)

各个地方缺少逗号。输出变量声明后: -

@Advance_payment varchar(50)输出

@Loading_date日期输出

在[advance_payment]之后的select语句中:

@Advance_payment = [advance_payment]