Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Silly SQL Server question

Options
  • 09-08-2007 10:27am
    #1
    Registered Users Posts: 3,964 ✭✭✭


    I am trying to learn a bit about ASP.NET 2.0 and SQL Server 2005 with the help of a book called "Beginning ASP.NET 2.0 and Databases".
    There are code downloads with the book that contain tables, views, stored procedures etc. already created for use with the ASP pages (stored within files with a .MDF extension) but I am wondering how are these files created?
    I have used Oracle and am familiar with creating tables, stored procedures etc. from the Oracle console in the Start menu. I have also done it with TOAD. How is it done with SQL Server?
    Appreciate any replies.


Comments

  • Registered Users Posts: 68,317 ✭✭✭✭seamus


    SQL Server 2005 includes a SQL Server Management studio, which is basically a management console for the server.

    .MDF files are the primary database files - in this case they've supplied you with the whole database, tables procedures, indexes etc., within the .MDF file.

    When you create a database in the Management Studio (either through SQL queries or using the dialog boxes), it creates the .MDF file for the database - you can specify the name & location of this file at creation time, or if not it will use the defaults.


  • Registered Users Posts: 3,964 ✭✭✭lukin


    Even though I have SQL Server, I don't have the Management Studio, I had to d'load it separately. It's SQL Server Management Studio Express, but it's not the Express edition of SQL Server I have, it's the full one, I assume it will work fine with it.


  • Registered Users Posts: 2,931 ✭✭✭Ginger


    Download the SQL Management Studio Express... this acts something similar to both Enterprise Manager for SQL 2000 and Query Analyser(TOAD-like thingy but not as good)

    The MDF is the data file for the Database.. creates an LDF file which is the log files..


  • Registered Users Posts: 2,781 ✭✭✭amen


    if you have Visual Studio then you can connect to your sql server instance from there and create a new database based on the mdf

    or you could use t-sql and connect via command line and attach the database that way


  • Registered Users Posts: 68,317 ✭✭✭✭seamus


    lukin wrote:
    Even though I have SQL Server, I don't have the Management Studio, I had to d'load it separately. It's SQL Server Management Studio Express, but it's not the Express edition of SQL Server I have, it's the full one, I assume it will work fine with it.
    You can only install the main Management Studio through the installation media for SQL Server (whatever version you have). The express one is more-or-less the same, just with some functionality removed.
    For development purposes, the Express edition is fine.


  • Advertisement
  • Registered Users Posts: 1,078 ✭✭✭db


    You will need to attach the .mdf file to be able to see the data in the file. You cannot point directly to the file when you create a database or you will overwrite it.


  • Registered Users Posts: 68,317 ✭✭✭✭seamus


    Without giving you the whole left-click, right-click stuff, you can attach the database with a query. You'll need to copy the .MDF file into a folder on your hard drive that most users will have access to - that is, it can't be on a CD or a network drive, or in your personal profile. the run the below query;
    USE [master]
    GO
    CREATE DATABASE [database_name] ON 
    ( FILENAME = N'C:\path\to\datafile.mdf' )
     FOR ATTACH
    GO
    
    It will then create the database with that name and all defaults. It will also create a log file for you - the result message will tell you where it created it (I think it will create it in the same folder as the mdf).


Advertisement