Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7593613
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T21:12:48+00:00 2026-05-30T21:12:48+00:00

When I am trying to carry out following statement from Management Studio, it is

  • 0

When I am trying to carry out following statement from Management Studio, it is executed successfully –

exec [sp_GetAllBillsForDate] '03/06/2012','03/06/2012'

enter image description here

But when I change it to

exec [sp_GetAllBillsForDate] getdate(), getdate()

enter image description here

it is generating error

Incorrect syntax near ')'.

whats wrong with this?

Thanks for sharing your time.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T21:12:50+00:00Added an answer on May 30, 2026 at 9:12 pm

    The answer is that you can’t pass a function as an argument to a stored procedure parameter.

    If you just want to use the current date/time when you don’t want to pass values in, why not make those parameters optional by supplying a default value inside the procedure? This will save you from having to type it, declare local variables, and even more importantly from passing those useless tokens from client applications.

    You should also avoid ambiguous date formats like m/d/y and d/m/y. If it wasn’t March right now, I’d have no idea whether you meant March 6 or June 3. And when you run your code somewhere with different regional or language settings, SQL Server might get it wrong too. State it unambiguously in a clear format (e.g. YYYYMMDD) immune to language, region or human perception issues.

    Anyway here is the procedure with optional parameters:

    ALTER PROCEDURE dbo.sp_GetAllBillsForDate -- sp_ is a horrible prefix, by the way *
        @date1 DATETIME = GETDATE(),
        @date2 DATETIME = GETDATE()
    AS
    BEGIN
        SET NOCOUNT ON;
        ...
    END
    GO
    

    Now the code for a hard-coded date:

    EXEC dbo.sp_GetAllBillsForDate @date1 = '20120306', @date2 = '20120306';
    

    And to get todays:

    EXEC dbo.sp_GetAllBillsForDate;
    

    (Also a good idea to explicitly name your parameters. Then you don’t have to worry about the parameter order changing. And also to always use the schema prefix when referencing or creating all objects.)

    • http://www.sqlmag.com/article/tsql3/should-i-use-the-sp_-prefix-for-procedure-names-
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to carry out a jsp page with some functionalities of Jquery. But,
I'm trying to figure out how to get a string from an array starting
I currently trying to carry out the same operation (OCR) on images in android,
I'm trying to select data from a table defined similar to the following :
I'm trying to carry out tip.disparity function in the geiger package in R. My
Trying to make a MySQL-based application support MS SQL, I ran into the following
Trying to create a QtRuby application, I get the following error: /usr/lib64/ruby/site_ruby/1.8/Qt/qtruby4.rb:2144: [BUG] Segmentation
Trying to do this sort of thing... WHERE username LIKE '%$str%' ...but using bound
I'm trying to do the following: I have two sets of DOM elements on
UPDATE OK, I figured it out. I had to call the following for varieties:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.