????? ????? ?????? ????? ????????? ?????? ?????? SQL Server ?? SQL Server Express

?????? ????????? ?????? ?????????
???? ???????: 2019698 - ??? ???????? ???? ????? ????? ??? ???????.
????? ???? | ?? ????

??????

?? ???? ??????? SQL Server Express ????? ?????? ?????? ?? ??? ??????? ???? ?? ??? ????? ???? ???? SQL Server ?? ??? ?????????. ?????? ???? ????? ??? ????? ??????? ????? ???????? ??? ??????? ??? ?????.   

????? ?????????? SQL Server Express ????? ????????? ?????? ???????? ?????? ??? ???????? ??? ???????? ???????:

??????? SQL Server ????? Studio Express. ??? ????? ??? ??? ???? ????? Express ?? SQL Server ?? ???? ???? SQL Express ??????. ????? ?? ?????????? ????? ??? ???? ???? ????? Microsoft (MSDN) ?????? ??? ?????:

????? ???? ???????? ????? ?? ????? ?????? (SQL Server)

  • ??????? ?????? ??? SQL ???????? ???? ?????? ?????? "????? ????????? ????? ??????" ???????. ????? ?? ?????????? ????? ??? ???? MSDN ?????? ??? ?????:

    ????? ????????? (Transact SQL)

    ???? ??? ??????? ????? ??????? ?????? ??? SQL ???????? ??? ???? ???? ????? ???? Windows ?????? ????? ????????? ?????? ?????? SQL Server Express ?? ?????? ?????.

  • ??????? ????

    ??? ???? ????? ??? ??????? ?????? ???? ????? ?????? SQL Server ???????? ?????? ????? ?????? ?? Windows:

    ?????? ?: ??????? SQL Server ????? Studio Express ?? Sqlcmd ?????? ??????? ?????? ?? ????? ???????? ????????:

    ???? ????? © ???? Microsoft.  ???? ?????? ??????.

    ??? ????????? ???????? ??? ??????

    //??????? ????? ? Microsoft (MS ??? http://opensource.org/licenses/ms-pl.html.)

    ??????? [???????]
    GO 
    /* * * ??????: StoredProcedure [dbo].[sp_BackupDatabases] */
    "????? ANSI_NULLS ???"
    ????????
    ????? ON QUOTED_IDENTIFIER
    ????????
    -= = =
    -??????: Microsoft
    -????? ?????: 2010-02-06
    -???: "????? ?????? ????? ?????????" ? SQLExpress
    -????? 1: ??? ????? ????????
    -????? 2: ????????? ? D = ????? ????????? L = = ?????
    -????? 3: ???? ??? ????? ?????????
    -= = =
    ????? ??????? [dbo]. [sp_BackupDatabases]
    @databaseName sysname = null?
    @backupType CHAR(1)?
    @backupLocation nvarchar(200)
    ???
    ? ??????? NOCOUNT ON 
               
                DECLARE @DBs TABLE
                (
                      ID int IDENTITY PRIMARY KEY,
                      DBNAME nvarchar(500)
                )
               
                 -- Pick out only databases which are online in case ALL databases are chosen to be backed up
                 -- If specific database is chosen to be backed up only pick that out from @DBs
                INSERT INTO @DBs (DBNAME)
                SELECT Name FROM master.sys.databases
                where state=0
                AND name=@DatabaseName
                OR @DatabaseName IS NULL
                ORDER BY Name
               
                -- Filter out databases which do not need to backed up
                IF @backupType='F'
                      BEGIN
                      @DBs ??? ??? DBNAME ?? ('??????'? 'Northwind' ''? 'AdventureWorks')
    ?????
    @backupType "??? ???" = ?? '
    ???
    @DBs ??? ??? DBNAME ?? (' ?????? '?' Northwind '' '' ???????? '?' AdventureWorks ')
    ?????
    @backupType"??? ???"=' ? '
    ???
    @DBs ??? ??? DBNAME ?? (' ?????? '?' Northwind '' '' ???????? '?' AdventureWorks ')
    ?????
    ELSE
    ???
    ??????
    ?????
    -????? ???????
    DECLARE @BackupName varchar(100)
    DECLARE @BackupFile varchar(100)
    DECLARE @DBNAME varchar(300)
    DECLARE @sqlCommand NVARCHAR(1000)
    DECLARE @dateTime NVARCHAR(20)
    int @ ???? ?????
    -??????? ?????? ??? ????? ???????? ?? ??? ???
    @ ?????? ????? = @DBs ?? min(ID)
    ????? @Loop IS NOT NULL
    ???
    -" ????? ????? ???????? "??? ?? ???? ?? ??? [dbname] ??? ??? ???-?? _ ??????
          @DBNAME ?????? = '[' +(SELECT DBNAME FROM @DBs WHERE ID = @Loop) + ']'
    -????? ????? ??????? ? ??????? ?????? ??????
    @dateTime ?????? = ??????? (????? (VARCHAR? '_' + GETDATE(),101),'/','') + ??????? (????? (VARCHAR? GETDATE(),108),':','')
    -????? ??? ??? ????? ????????? ?? ????? path\filename.extension ????? ????????? ?????? ????????? ????
    @backupType ??? = '?'
    @BackupFile ?????? = @backupLocation + ??????? (??????? (@DBNAME? '['? '')? ']'? '') @dateTime+ + '_FULL_' '.??? '
    @backupType"??? ???"=' ? '
    @BackupFile ?????? = @backupLocation + ??????? (??????? (@DBNAME?' ['? '')?'] '? '') @dateTime+ +' _DIFF_ ''.??? '
    @backupType ELSE IF' ? ' =
    @BackupFile ?????? = @backupLocation + ??????? (??????? (@DBNAME?' ['? '')?'] '? '') @dateTime+ +' _LOG_ ''.TRN'
     
    -- Provide the backup a name for storing in the media
          IF @backupType = 'F'
                SET @BackupName = REPLACE(REPLACE(@DBNAME,'[',''),']','') +' full backup for '+ @dateTime
          IF @backupType = 'D'
                SET @BackupName = REPLACE(REPLACE(@DBNAME,'[',''),']','') +' differential backup for '+ @dateTime
          IF @backupType = 'L'
                SET @BackupName = REPLACE(REPLACE(@DBNAME,'[',''),']','') +' log backup for '+ @dateTime
     
    -- Generate the dynamic SQL command to be executed
     
           IF @backupType = 'F' 
                      BEGIN
                   SET @sqlCommand = 'BACKUP DATABASE ' +@DBNAME+  ' TO DISK = '''+@BackupFile+ ''' WITH INIT, NAME= ''' +@BackupName+''', NOSKIP, NOFORMAT'
                      END
           IF @backupType = 'D'
                      BEGIN
                   SET @sqlCommand = 'BACKUP DATABASE ' +@DBNAME+  ' TO DISK = '''+@BackupFile+ ''' WITH DIFFERENTIAL, INIT, NAME= ''' +@BackupName+''', NOSKIP, NOFORMAT'        
                      END
           IF @backupType = 'L' 
                      BEGIN
                   SET @sqlCommand = 'BACKUP LOG ' +@DBNAME+  ' TO DISK = '''+@BackupFile+ ''' WITH INIT, NAME= ''' +@BackupName+''', NOSKIP, NOFORMAT'        
                      END
     
    -- Execute the generated SQL command
           EXEC(@sqlCommand)
     
    -- Goto the next database
    SELECT @Loop = min(ID) FROM @DBs where ???? > @Loop
    ???????

    ?????? ?: ?? ???? ??? ????? ??? ???? ???? Sqlbackup.bat ?? ?? ???? ???? ?? ??? ??????? ??????? ??? ??? ?????? ???????? ??? ????????? ????? ??:

    Example1:????? ????????? ?????? ???? ????? ???????? ?? ???? ???? ?????? SQLEXPRESS ???????? ?????? Windows

    Sqlbackup.bat

    sqlcmd-S. \EXPRESS-E-Q "EXEC sp_BackupDatabases @backupLocation = ??: \SQLBackups\'? @backupType = '?'" 

    Example2: ???????? ???? ????? ???????? ?? ???? ???? ?????? SQLEXPRESS ???????? ???? ?????? ?????? ?? ????????

    Sqlbackup.bat

    sqlcmd-U ???????-P ???? ??????-S. \SQLEXPRESS-Q "EXEC sp_BackupDatabases @backupLocation =' D:\SQLBackups '? @BackupType =' ? '"

    ??????: "???????" ???????? ??? ????? ??? "???? ????? ????? ?????????" ?? SQL Server.


    ???? ?????? 3:????? ????????? ???? ????? ???????? ?? ???? ???? ??????? ?? SQLEXPRESS ???????? ?????? Windows ????

    Sqlbackup.bat

    sqlcmd-S. \SQLEXPRESS-E-Q "EXEC sp_BackupDatabases @backupLocation = ??: \SQLBackups\'? @backupType = '?'"

    ???? 4:?????? ??? ??????? ????? ?????? ?????? ??????? ?? ???? ???? ??????? ?? SQLEXPRESS ???????? ?????? Windows

    Sqlbackup.bat

    sqlcmd-S. \SQLEXPRESS-E-Q "EXEC sp_BackupDatabases @backupLocation = ??: \SQLBackups\'? @databaseName = '???????'? @backupType = '?'"

    ???????? ????? ??? ???????? ????? ????????? ???????? ???? ?? ?? '??????? @backupType ????? ???????? ??? ?? ??????? ????' ? ' ??????? @backupType .

    ?????? c:????? ??????? ???????? ?????? ????? ?????? ? Windows ?????? ????? ?????? ???? ??? ??????? ?? ?????? ?. ?????? ????? ???? ??????? ???????:

    1. ??? ????????? ???? ???? ?????? SQL Server Express? ???? ??? ???????? ??? ???? ???????? ??? ??? ??????? ???????? ???? ??? ????? ??????? ??? ???? ??? "?????? ????????". 
    2. ???? ????? ??????? ??? ????? ???? ??????. 
    3. ?? "????? ?????? ????????"? ???? ??? " ??????". 
    4. ???? ??? ???????????? ??? ??? ??????? ???? ??? ??????? ?? ?????? B ?? ???? ??? ???. 
    5. ???? ???????? ???? ??????? ???? ??? ??????? ?? ???? ??? ??????. 
    6. ????? ??????? ????? ?????? ??????. (???? ?????? ??? ?????? ??? ????? ??? ????? ?? ???.) ?? ???? ??? ??????.
    7. ?? ????? ???? ??? ???????? ? ???? ??? ??????? ??? ?? ???? ???? ???? ?? ??? ????? ???? ?????? .

      ?????? ??? ???????? ??? ??? ????? ????? ??? ????????????? ?? ????? SQL Server ??? ??? ?????? ??? ??????? ???? ?? ?????? 1 ?? 3 ?? 4.
    8. ???? ??? ??????? ??? ?? ???? ??? ?????. 
    9. ????? ?????? ???????? ??? ????? ??? ????? ?????? ?? ??? ??? ????? ?????? ?????????? ?????.

      ?????????? ????? ???????? SQLCMD ??? ????? ?? ??????? ?????? ?????? ??? ????? SQL Server? ???? ??? ?? ??? ????? ???? ??? ??????? ????? ?????? ????? ??? \90\Tools\Binn < ???? ??????? > (??? ???? ??????: C:\Program ?????????? SQL Server\90\Tools\Binn)-

      ???? ??? ??? ??? ??? ??? ??????? ??????? ??????? ?? ??? ???????:

      • ??? ????? ???? ????? ?????? ?? Windows ?? ????? ???? ??? ????? ?????? ???????. ???? ?????? ??? ??? ??????? ????? ??? ????????. ???? ???? ?? ????? ?????? ??? ??? ????? ?????.
      • ??? ?? ???? ???? ?????? ?? ??????? ??? ???? ??????? ???? ??? ????? ????? ??????????. ???? ?????? ??????? ??????? ???????? ?? ???? ?????? ?????????? ???? ????? ?????? ?? ??? ?? ???? ????? ?????. ?? ????? ???????? ????? ??? ?????? ?????? ??????? ???????.

      ????? ??????

    ???????

    ???? ???????: 2019698 - ????? ??? ??????: 25/?????/1435 - ??????: 2.0
    ????? ???
    • Microsoft SQL Server 2014 Express
    • Microsoft SQL Server 2012 Express
    • Microsoft SQL Server 2008 Express
    • Microsoft SQL Server 2008 Express with Advanced Services
    • Microsoft SQL Server 2005 Express Edition
    • Microsoft SQL Server 2005 Express Edition with Advanced Services
    ????? ??????: 
    kbmt KB2019698 KbMtar
    ????? ????
    ???: ??? ????? ??? ??????? ???????? ????? ?????????? ??????? ?????? ??? ??????? ?? ??? ??????? ?? ??????? ??? ??? ?? ???? ????????? ???? ??????? ???????(CTF) ?? ?? ???? ????? ????. ???? ?? ???? ?????????? ??? ???????? ???????? ???? ??? ?? ???????? ??????? ?? ??? ??????? ???????? ?? ??? ??????? ??????? ??? ?????? ?? ?????? ??? ???? ???????? ???????? ?? ????? ??????? ????? ????? ??????. ??? ?? ???????? ???????? ?? ????? ??? ????? ?? ???????? ?? ???? ????? ?? ?????. ?????? ??? ???? ?????????? ???? ?????? ?? ??? ????? ?? ??? ??? ?? ??????? ?? ??? ????? ?? ???? ????? ????? ?? ????? ??????? ???? ?? ???????? ?? ??? ???????.
    ???? ??? ????? ??????? ?????? ??????????2019698

    ????? ???????

     

    Contact us for more help

    Contact us for more help
    Connect with Answer Desk for expert help.
    Get more support from smallbusiness.support.microsoft.com