SQL Server Accumulation

Source: Internet
Author: User
Tags import database
  1. Error 1069-(unable to start the service due to logon failure .), The operation is being performed on the MSSQLServer service.
    There are already many solutions to this problem on the Internet. The simplest solution is to reinstall sqlserver and choose Windows logon verification;
    Alternatively, on the control panel, find the sqlserver service component in the Service Manager and modify the logon mode information. The last method is to create a Windows user and use it as the sqlserver login user.
  2. Create a database
    Create script
    Create Database sqldb on primary
    (Name = sqldbdata,
    Filename =
    'F:/sqlserverfile/sqldbdata. MDF ',
    Size = 20 mb,
    Max size = 100 MB,
    Filegrowth = 10 MB)
    Log On
    (Name = sqldblog,
    Filename =
    'F:/sqlserverfile/sqldblog. ldf ',
    Size = 5 MB,
    Maxsize = 15 MB,
    Filegrowth = 1 MB)
    Go
    Note: It is best to create a directory to store relevant database files when creating a database.
    When creating a database, many people will encounter the following error message:
    Failed to obtain the exclusive lock on the database 'model. Please try again later.
    Server: Message 1802, level 16, status 1, Row 1
    Create Database failed. Failed to create some listed file names. Check the preceding error message.
    My solution is to restart the computer. If there is a good solution for this problem, please add it.
  3. . MDF,. LDF File Import Database
    If you have. MDF and. LDF files, you can import them to sqlserver.
    Method 1:
    Run the following command in the query Analyzer:
    Exec sp_attach_db 'databas _ name', '*. MDF file path',' *. LDF file Path'
    The three parameters after the exec sp_attach_db command are database name, MDF file path, and LDF file path. Each parameter is separated by commas (,). The database name does not exist on the current server.
    Example:
    Exec sp_attach_db 'oa'
    , 'F:/Eclipse/workspace/OA/webroot/datebase/oa_data.mdf'
    , 'F:/Eclipse/workspace/OA/webroot/datebase/oa_log.ldf'
    Method 2:
    In the Start Menu, find the "Enterprise Manager" program in the MS sqlserver directory and follow the path below.
    Enterprise Manager --> database --> right-click --> all tasks --> attach database --> select. MDF file
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.