CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Jan 2007
    Location
    Belgium
    Posts
    12

    MS SQL SERVER Queries/views with user input

    Hi,

    I would like to create some queries (actually, preferrably views) in ms sql server that allow for user input. The reason why I want this, is because I am trying to generate some reports about my data using excel (for example periodical reports, in which case I would have to give the queries a start- and enddate), but I would rather keep all the complex database-stuff inside sql server.

    Can anyone tell me if this is possible?

    Thanks

  2. #2
    Join Date
    Nov 2004
    Location
    Poland
    Posts
    1,355

    Re: MS SQL SERVER Queries/views with user input

    Can anyone tell me if this is possible?
    Yes - using Stored Procedures.

  3. #3
    Join Date
    Jun 2006
    Posts
    437

    Re: MS SQL SERVER Queries/views with user input

    Hi all.
    Generally using views to "export" data from a database is a good way to manage reports.
    If you're going to use Excel for data analysis, you may be write a Excel-macro that connects to database, extracts data and puts them in the sheets (I've done this yet, with a Oracle database).

    @Krzemo. A view is a "stored-query"; why do one should use stored procedures?
    Last edited by davide++; January 9th, 2007 at 07:33 AM.

  4. #4
    Join Date
    Nov 2004
    Location
    Poland
    Posts
    1,355

    Re: MS SQL SERVER Queries/views with user input

    A view is a "stored-query"; why one should use stored procedures?
    Since stored procedures accepts parameters and it is faster and safer than an ad hoc query that use view.

    And a view sometimes leads to strange errors when U alter some underlying tables without refreshing view definition.


    Krzemo.

  5. #5
    Join Date
    Jun 2006
    Posts
    437

    Re: MS SQL SERVER Queries/views with user input

    Ha, OK.
    You meant stored procedure as alternative for view; I thought you spoke about stored procedure as a way to create the views, and this was quite strange for me (nevertheless one can use a stored procedure to write records in a table, and then using the table as a view).

    I agree.
    Furthermore, a stored procedure may be easier to develop rather than a complex query.
    Last edited by davide++; January 9th, 2007 at 07:34 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured