extracting data from SQL database

  • Hi,

    I am new to the SQL world, and it's a pleasure to meet you.

    I am running an hotel application for all the bookings.

    I would like to get all the data of all the guests that stayed in the hotel (name, stay duration and dates, payment, etc).

    However, the GUI would make me go over one booking at a time, which would take me forever.

    The application has an SQL database locally on my computer.

    Will I be able to use SQL server and extract all the guests data from the last year and export it into a file, e.g. A CSV file?

    Id appreciate your guidelines.

    Thank you very much.

    Best regards,

    Joe

  • Welcome!

    Based on what you have told us, the answer is yes.

    But we cannot tell you exactly how without knowing how the database is structured.

    Details of guests, periods of stay and billing information will all be in the database ... somewhere. Spread across different tables.

    The hard work will be getting to understand the database structure. Once you know that, getting the data out will be relatively simple.

    If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.

  • You can, but you need to know how the tables are designed, define what you want to retrieve and create adequate queries.

    An incorrect query will work and give incorrect data, so you need to be sure about what you're doing.

    I'd suggest that you go read the Stairway series on T-SQL in this site to get you up to speed: http://www.sqlservercentral.com/stairway/

    After that, come back and post specific questions that you might have.

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • Hi,

    I very appreciate your answers!

    That was what I was looking for, knowing what I need to focus on in order to retrieve the guests data.

    So I need to learn about SQL structures, right?

    And then, how to set up SQL queries in order to retrieve the data from the structures.

    Would it be possible to arrange all the different data (name, biiling, dates of stay, etc) into one file?

    Can it be done automatically for the entire guests?

    Thank you.

  • Once you can create the query to return all the information, you can program it to export it to a single file automatically.

    Some problems you can find is when you have one guests that has billing information for the stay and for other charges, or maybe did different payments. Depending on how the database is designed, this can cause rows to be partially repeated (same guest, same stay, different billing/payment information).

    That's why you need to be careful before sending anything or relying on queries without testing them.

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • Thank you very much.

    Is the stairway link a good quick way to understand how to retrieve the data from the structures?

    Could you please refer me to a specific link in the stairway?

    I would need to extract it by next week, hopefully.

    Thanks a million!

  • programme (11/5/2015)


    Thank you very much.

    Is the stairway link a good quick way to understand how to retrieve the data from the structures?

    I would need to extract it by next week, hopefully.

    Thanks a million!

    The Stairway links are an excellent place to start. I suggest that you get SQL developer edition and install it on your local machine. Or, if you have a sandbox server to use, install it there.

    The Stairways use the AdventureWorks database which is a sample database provided by Microsoft in the examples.

    Michael L John
    If you assassinate a DBA, would you pull a trigger?
    To properly post on a forum:
    http://www.sqlservercentral.com/articles/61537/

  • Thank you.

    Where.in the stairway page should I go to?

    There are different links there.

  • programme (11/5/2015)


    Thank you.

    Where.in the stairway page should I go to?

    There are different links there.

    All of them!

    You actually have two different aspects of learning, the theory as well as the usage.

    The theory is covered in the Stairway to Data and the Stairway to Database Design by Joe Celko. This is the "WHAT".

    The HOW is covered in the Stairway to T-SQL DML and Stairway to T-SQL: Beyond the Basics by Greg Larson

    Michael L John
    If you assassinate a DBA, would you pull a trigger?
    To properly post on a forum:
    http://www.sqlservercentral.com/articles/61537/

  • This was removed by the editor as SPAM

  • This was removed by the editor as SPAM

Viewing 11 posts - 1 through 10 (of 10 total)

You must be logged in to reply to this topic. Login to reply