+ Reply to Thread
Results 1 to 5 of 5

How execute stored procedure from Management Studio?

  1. How execute stored procedure from Management Studio?

    I am trying to execute a stored procedure from the query window in
    Management Studio Express. The proc requires a DateTime parameter and I
    cannot find a way to use a literal for the date. I have tried

    EXECUTE MONITORINGINVOICES @BillingDate =
    CAST('2008-04-0104T00:00:00.000' AS DateTime), @BatchNumber = 'xx1',
    @User_Id = 'Bill', @InvoiceCount = 0

    and every other variant of CAST and CONVERT I can think of but I always
    get a "Incorrect syntax near '2008-04-0104T00:00:00.000'" near the date
    literal. How can I run this stored proc from Management Studio?
    Thanks.

    --
    ..Bill.

  2. Re: How execute stored procedure from Management Studio?

    On Mar 22, 7:37*pm, "Bill" wrote:
    > I am trying to execute a stored procedure from the query window in
    > Management Studio Express. The proc requires a DateTime parameter and I
    > cannot find a way to use a literal for the date. I have tried
    >
    > EXECUTE MONITORINGINVOICES @BillingDate =
    > CAST('2008-04-0104T00:00:00.000' AS DateTime), @BatchNumber = 'xx1',
    > @User_Id = 'Bill', @InvoiceCount = 0
    >
    > and every other variant of CAST and CONVERT I can think of but I always
    > get a "Incorrect syntax near '2008-04-0104T00:00:00.000'" near the date
    > literal. How can I run this stored proc from Management Studio?
    > Thanks.
    >
    > --
    > .Bill.


    Looks like you have a typo in your example:

    2008-04-0104T00:00:00.000 is not a valid date; 2008-0401T00:00:00.000
    is.

    You should be able to just use @BillingDate =
    '2008-04-01T00:00:00.000', BTW.

    Stu

  3. Re: How execute stored procedure from Management Studio?


    >"Stuart Ainsworth" wrote in message
    >news:d6c61f19-1443-46a5-b3c5-bec5a2305aba@u69g2000hse.googlegroups.com...
    >On Mar 22, 7:37 pm, "Bill" wrote:
    >> I am trying to execute a stored procedure from the query window in
    >> Management Studio Express. The proc requires a DateTime parameter and I
    >> cannot find a way to use a literal for the date. I have tried
    >>
    >> EXECUTE MONITORINGINVOICES @BillingDate =
    >> CAST('2008-04-0104T00:00:00.000' AS DateTime), @BatchNumber = 'xx1',
    >> @User_Id = 'Bill', @InvoiceCount = 0
    >>
    >> and every other variant of CAST and CONVERT I can think of but I always
    >> get a "Incorrect syntax near '2008-04-0104T00:00:00.000'" near the date
    >> literal. How can I run this stored proc from Management Studio?
    >> Thanks.
    >>
    >> --
    >> .Bill.

    >
    >Looks like you have a typo in your example:
    >
    >2008-04-0104T00:00:00.000 is not a valid date; 2008-0401T00:00:00.000
    >is.
    >
    >You should be able to just use @BillingDate =
    >'2008-04-01T00:00:00.000', BTW.
    >
    >Stu

    Actually, it's not just true that you CAN use @BillingDate =
    '2008-04-01T00:00:00.000', you MUST either do that (which will implicitly
    convert the string to a datetime - that is not a problem since you have
    correctly used one of the unambigous datetime formats) or assign the result
    of the Cast() function to a variable and then pass that variable. You can
    only pass values or variables as parameters, you are not allowed to pass an
    expression. So either of the following is legal and should get you what you
    want:

    EXECUTE MONITORINGINVOICES @BillingDate = '2008-04-01T00:00:00.000',
    @BatchNumber = 'xx1',
    @User_Id = 'Bill', @InvoiceCount = 0

    or

    Declare @TempDate datetime
    Set @TempDate = CAST('2008-04-01T00:00:00.000' AS DateTime)
    EXECUTE MONITORINGINVOICES @BillingDate = @TempDate, @BatchNumber = 'xx1',
    @User_Id = 'Bill', @InvoiceCount = 0

    Tom



  4. Re: How execute stored procedure from Management Studio?

    Thanks. It is obviously time to quite for tonight.

    --
    ..Bill.

  5. Re: How execute stored procedure from Management Studio?

    Thanks for the detailed explanation.

    --
    ..Bill.

+ Reply to Thread