Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3492886
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T11:48:51+00:00 2026-05-18T11:48:51+00:00

What I would like is to combine the two files into one bat file

  • 0

What I would like is to combine the two files into one bat file but currently sqlcmd stops with the sqlqcmd prompt and the SQL is not running.

Ouch server went bang so I need to put contingency in place PDQ

I normally use SQL server agent with some jobs but while the new server is being sorted. I only have SQL express No SQL server agent.

Fine my so I have created a backup.bat it works fine in cmd calling backup.sql the sql send it to another drive.

The statement I used is:-

Sqlcmd –S \mypc\instancename –i C:\backup.sql( as I am local window authentication is fine)

This is so that i can use task scheduler in not very friendly windows 7

At the moment I have a .bat file calling a .sql file.

Backup.bat

Sqlcmd –S \mypc\instancename –i C:\backup.sql 

Backup.sql

BACKUP DATABASE [Northwind] TO  DISK = N'\\nas1\backup\northwind.bak' WITH NOFORMAT, INIT,  NAME = N'Northwind-Full Database Backup', SKIP, NOREWIND, NOUNLOAD,  STATS = 10
GO
declare @backupSetId as int
select @backupSetId = position from msdb..backupset where database_name=N'Northwind' and backup_set_id=(select max(backup_set_id) from msdb..backupset where database_name=N'Northwind' )
if @backupSetId is null begin raiserror(N'Verify failed. Backup information for database ''Northwind'' not found.', 16, 1) end
RESTORE VERIFYONLY FROM  DISK = N'\\nas1\backup\Northwind.bak' WITH  FILE = @backupSetId,  NOUNLOAD,  NOREWIND
GO

What I want is to combine the two files into one bat file but currently sqlcmd stops with the sqlcmd prompt and the SQL is not running.

Sqlcmd –S \mypc\instancename  
BACKUP DATABASE [Northwind] TO  DISK = N'\\nas1\backup\northwind.bak' WITH NOFORMAT, INIT,  NAME = N'Northwind-Full Database Backup', SKIP, NOREWIND, NOUNLOAD,  STATS = 10
GO
declare @backupSetId as int
select @backupSetId = position from msdb..backupset where database_name=N'Northwind' and backup_set_id=(select max(backup_set_id) from msdb..backupset where database_name=N'Northwind' )
if @backupSetId is null begin raiserror(N'Verify failed. Backup information for database ''Northwind'' not found.', 16, 1) end
RESTORE VERIFYONLY FROM  DISK = N'\\nas1\backup\Northwind.bak' WITH  FILE = @backupSetId,  NOUNLOAD,  NOREWIND
GO
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T11:48:51+00:00Added an answer on May 18, 2026 at 11:48 am

    I found using two files works

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two views that I would like to combine into one. The first
I would like to combine the functionality of two arguments to one. Currently -f
In javascript I would like to combine two objects into one. I got {
I would like to combine these four queries into one: SELECT COUNT(ID) FROM conversations
I have these 2 queries that I would like to combine into one big
I would like to combine entries from the second field from two files using
I have 2 files, somefile.h and somefile.m . I would like to combine them
I have two png image files that I would like my android app to
I would like some tool, preferably one that plugs into VS 2008/2010, that will
I need to combine two URL's that both contain .Path information. I would like

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.