0

나는bat 파일을 통해 SQL Server 2014 db 데이터를 백업하는 방법은 무엇입니까?

Sqlcmd: Error: Microsoft ODBC Driver 11 for SQL Server : SQL Server Network Inte rfaces: Connection string is not valid [87]. Sqlcmd: Error: Microsoft ODBC Driver 11 for SQL Server : Login timeout expired. Sqlcmd: Error: Microsoft ODBC Driver 11 for SQL Server : A network-related or in stance-specific error has occurred while establishing a connection to SQL Server . Server is not found or not accessible. Check if instance name is correct and i f SQL Server is configured to allow remote connections. For more information see SQL Server Books Online..

사람이 도와주세요 수,

sqlcmd -S .\MSSQLSERVER -E -Q "EXEC sp_BackupDb @backupLocation='D:\SQLBackups\', @databaseName='TestDb', @backupType='F'" pause 

그것은이 오류를 던지고, DB 접속 백업 박쥐 파일에서이 쿼리를 사용하고? 미리 감사드립니다.

+0

서버 이름 사양에서 인스턴스 이름을 제거하는 것이 좋습니다 :'-S. \ MSSQLSERVER' 대신'-S .'. –

+0

sqlcmd -S. \ MSSQLSERVER -E -Q "select 1"은 오류를 반환합니까? – PollusB

답변

0

당신은 예를 들어 stackoverflow link

SQLCMD가이 링크에서,이 bakcup을 확인하기 위해 박쥐 파일에 SQLCMD을 사용할 수 있습니다 : 여기

The sqlcmd utility lets you enter Transact-SQL statements, system procedures, and script files at the command prompt, in Query Editor in SQLCMD mode, in a Windows script file or in an operating system (Cmd.exe) job step of a SQL Server Agent job. This utility uses OLE DB to execute Transact-SQL batches.

는 예와 정의에 대한 링크입니다 : 예를 들어 msdn link definition

:

sqlcmd -E -S %SERVERNAME% -d master -Q "BACKUP DATABASE [%DATABASENAME%] TO DISK = N'%BACKUPFILENAME%' WITH INIT , NOUNLOAD , NAME = N'%DATABASENAME% backup', NOSKIP , STATS = 10, NOFORMAT" 

희망이 도움이됩니다!