??????? ?? SQL Server ????????? ??? SQL Server ??????? ?? ????? ?? ???????? ???? ?? ??? ????

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

??????

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

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

SQL ????? ??????? ???????? ????????? ?? ????? ????? ?? SQL Server ????????? ????? ???? ?? SQL Server ????????? ?????? ?? ??? ??????? ???? ??? ??? ???? ??????? ?? ???, ????? Microsoft ?????? ??????? (MSDN) ??? ???? ?? ????:

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

  • ?????? ?? ???? ????? ??????? ?? ????? ???? ?? ?? Transact SQL ????????? ?? ????? ????? ???? ??????? ?? ???, ????? MSDN ??? ???? ?? ????:

    ????? (?????? ????-SQL)

    ?? ???? ????? ???? ?? ?? ???? ??????? ?? ???? ?? SQL Server ????????? ??????? ?? ????? ?? ???????? ???? ?? ??? ??? Transact-SQL ????????? ?? ??? Windows ????? ???????? ?? ????? ???? ?????

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

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

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

    ???????? © Microsoft Corporation ???  ??? ?????? ?????????

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

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

    ?? ????? ???? [?????]
    GO 
    / *** ????????: StoredProcedure [dbo]?[sp_BackupDatabases] *** /
    ??? ANSI_NULLS ????
    ????
    QUOTED_IDENTIFIER ???? ???
    ????
    --===
    --????: Microsoft
    --??????? ??????: 2010-02-06
    --?????: SQLExpress ?? ??? ????? ???????
    --????????1: databaseName
    --????????2: backupType F ?????, D = ?????, L = ??? =
    --????????3: ????? ????? ?????
    --===
    ??????? ????????? [dbo]. [sp_BackupDatabases]
    @databaseName sysname = ?????,
    @backupType CHAR(1),
    @backupLocation nvarchar(200)
    AS
    ; NOCOUNT ???? ??? ???? 
               
                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 ??? ('tempdb', '?????????', 'pubs', 'AdventureWorks')
    ???
    ??? ??? ??? @backupType = ' ? '
    ????
    ????? @DBs ???? DBNAME ??? ('tempdb', '?????????', 'pubs', '??????', 'AdventureWorks')
    ???
    ??? ??? ??? @backupType = 'L'
    ????
    ????? @DBs ???? DBNAME ??? ('tempdb', '?????????', 'pubs', '??????', 'AdventureWorks')
    ???
    ????
    ????
    ????
    ???
    --?? ?????
    DECLARE @BackupName varchar(100)
    DECLARE @BackupFile varchar(100)
    DECLARE @DBNAME varchar(300)
    DECLARE @sqlCommand NVARCHAR(1000)
    DECLARE @dateTime NVARCHAR(20)
    ????? @ ??? int
    --?? ?? ??? ?? ??????? ?? ?????? ?? ???
    ?? ??? ???? @ ??? = min(ID) ?? @DBs
    @Loop IS ???? ??? ?? ????
    ???????
    --??????? ????? ?? _ ??? ???? ??? ?? ??? ??? ?? - [dbname] ?????? ??? ???? ?????
          ??? @DBNAME '[' +(SELECT DBNAME FROM @DBs WHERE ID = @Loop) +']' =
    --?? ??????? ?????? ?? ??? n yyyyhhmmss ?????? ???
    ??? @dateTime ????? = (?????? ???? (VARCHAR, GETDATE(),101),'/','') + '_' + ??? (?????? ???? (VARCHAR, GETDATE(),108),':','')
    --path\filename.extension ?????? ?????, ???? ?? ??? ????? ?? ??? ????? ????? ?????
    ??? @backupType '?' =
    ??? @BackupFile = @backupLocation + ??? (????? (@DBNAME, ' [', '),'] ', ') '_FULL_' + @dateTime+ + '?BAK'
    ?? ??? @backupType = ' ? '
    ??? @BackupFile = @backupLocation + ??? (????? (@DBNAME, ' [', '),'] ', ') '_DIFF_' + @dateTime+ + '?BAK'
    ?? ??? @backupType = 'L'
    @BackupFile ??? ???? = @backupLocation + ??? (????? (@DBNAME, ' [', '),'] ', ') '_LOG_' + @dateTime+ + '?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 ID > @Loop
    ???

    ??? B: ???? ??? ??????, ??? Sqlbackup.bat ??? ?? ?? ?? ??? ????? ?????, ?? ?? ??? ????? ?????? ??? ?? ?? ?? ???? ?????? ?? ???? ??, ?? ????? ??? ????????? ?????:

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

    Sqlbackup.bat

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

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

    Sqlbackup.bat

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

    ???: SQLLogin shouldhave ?? SQL ????? ??? ?? ?? ?? ????? ?????? ???????


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

    Sqlbackup.bat

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

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

    Sqlbackup.bat

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

    ??? ???, ?? ?? ????? ??????? ?? ?????? USERDB ?? ????? ?? ???? ??? ??? ' ? ' ?? 'L' ??? ??????? ?? ??? @backupType ???????? ?????? ??? ????? USERDB ?? @backupType ???????? ?? ????

    ??? c:????? ?? B. ??? ??? ???? ?? ??? ????? ?? ????????? ???? ?? ??? Windows ????? ???????? ?? ????? ???? ???? ??????? ??? ???? ?? ???, ????? ????? ?? ???? ????:

    1. SQL Server Express ??? ??? ???????? ??, ???????????? ????, ??? ??????????? ????? ????, ????? ??????? ????? ????, ?????? ??????? ????? ????, ?? ???? ??? ????? ??????? ???? ??? ??. 
    2. ????????? ????? ?????????-????? ????? 
    3. ????????? ????? ???????? ???, ????????? ????? 
    4. ?? ????? ???? ??????? ????, ?? ?? ??? B ??? ???? ?? ??? ????? ????? ????, ?? ?? ?????????? ????? 
    5. SQLBACKUP ?? ??? ????? ?? ??? ???? ????, ?????????? ????, ?? ?? ????????? ????? 
    6. ??????? ?? ??? ????? ?? ????? ?? ??? ??????? ????????? ????? (?? ?? ??? ?? ?? ?? ?? ??? ?? ????? ????? ??????? ???? ???.) ???? ???, ????????? ?????
    7. ?????????? ??? ???? ???? ?????? ???, ??? ?????????? ??? ???? ????, ?? ?? ???? ???? ??????? ?????? ??? ??????? ??????

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

      ???SQLCMD ???????? ????? ?? ??? ??????? ????? ?? ????? ?? ??? ?? ?? ???? ?? ??? SQL ????? ??????? ??, ????? ?? ??????? ?? ?? ?? ???? ???? ??, ?? ??? < ??????? ????? > \90\Tools\Binn ?? ??????? ??????? ?? ???? ??? ?? ??? ?? (?????? ?? ???: C:\Program Files\Microsoft SQL Server\90\Tools\Binn).

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

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

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

    ???

    ???? ID: 2019698 - ????? ???????: 23 ??? 2014 - ??????: 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 KbMthi
    ???? ?????? ????????
    ??????????: ?? ???? ?? ???? ??????? ?? ????? ?? Microsoft ????-?????? ?????????? ?????? ?????? ???? ??? ??. Microsoft ???? ??? ????-???????? ?? ????-???????? ????? ?????? ?? ???? ???????? ???? ?? ???? ????? ????? ??? ?? ??? ?????? ?? ???? ???? ???? ??? ????? ??. ???????, ????-???????? ???? ????? ???? ???? ???? ???. ?????, ????????, ?????-???? ?? ??????? ?? ???????? ?? ???? ???, ???? ?? ??? ?????? ???? ???? ??? ????? ??? ?? ???? ??. Microsoft ??????? ??? ???? ?? ?????? ?? ??????????, ????????? ?? ??? ?????? ?? ???? ????? ?? ???? ???????? ?? ??? ???? ????? ?? ??? ????????? ???? ??. Microsoft ????-?????? ?????????? ?? ????? ?????? ?? ?? ??? ??.
    ?????????? ?? ??????? ????????? ??????? ??: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