T-SQL Code to backup database with multiple files - Syntax error

Hello,
I'm trying to backup a database into multiple files but I'm getting a syntax error.
Here is the code:
declare @DBName varchar(100)
declare @DBFileName varchar(256)
declare @FolderName varchar(256)
declare @Path varchar(100)
set @Path = '\\Backup-Server\Test\'
set @DBName = 'DayNite'
set @DBFileName = 'DayNite-Full' + '-' + (SELECT CONVERT(char(10), GetDate(),110)) + '-' + 'P'
set @FolderName =(SELECT CONVERT(char(10), GetDate(),110))
set @Path = @Path + @FolderName + '\'
EXEC master.dbo.xp_create_subdir @Path
--Calculate broken files for BACKUP DATBASE Function
/*declare @dbsize int
set @dbsize = (SELECT ((size*8)/1024)/1000 as SizeGB FROM sys.database_files WHERE file_id = '1')
set @dbsize = @dbsize / 4
print @dbsize*/
EXEC
BACKUP DATABASE [test] TO
DISK = @Path + @DBFileName + '1.bak',
DISK = @Path + @DBFileName + '2.bak',
DISK = @Path + @DBFileName + '3.bak',
DISK = @Path + @DBFileName + '4.bak',
DISK = @Path + @DBFileName + '5.bak',
DISK = @Path + @DBFileName + '6.bak',
DISK = @Path + @DBFileName + '7.bak',
DISK = @Path + @DBFileName + '8.bak',
DISK = @Path + @DBFileName + '9.bak',
DISK = @Path + @DBFileName + '10.bak',
DISK = @Path + @DBFileName + '11.bak',
DISK = @Path + @DBFileName + '12.bak',
DISK = @Path + @DBFileName + '13.bak'
WITH INIT , NOUNLOAD , NAME = 'DayNite Full Backup', NOSKIP , NOFORMAT

Made some slight modifications to your script and it should work(worked when tested).. if you wnat more complete solution -- google  -OLA Hallengren backups  -- you should get some good scripts..
declare @DBName varchar(100)
declare @DBFileName varchar(256)
declare @FolderName varchar(256)
declare @Path varchar(100)
set @Path = '\\Backup-Server\Test\'
set @DBName = 'DayNite'
set @DBFileName = 'DayNite-Full' +''+ '-' +''+ (SELECT CONVERT(char(10), GetDate(),110)) +''+ '-' +''+ 'P'
set @FolderName =(SELECT CONVERT(char(10), GetDate(),110))
set @Path = @Path +''+ @FolderName +''+ '\'
EXEC master.dbo.xp_create_subdir @Path
--Calculate broken files for BACKUP DATBASE Function
/*declare @dbsize int
set @dbsize = (SELECT ((size*8)/1024)/1000 as SizeGB FROM sys.database_files WHERE file_id = '1')
set @dbsize = @dbsize / 4
print @dbsize*/
select @Path,@DbFileName
declare @SQL nvarchar(2000)
Set @SQL ='Backup DATABASE [DAYNITE] TO DISK = '''+@Path +''+ @DBFileName +''+ '1.bak'',
DISK = '''+@Path +''+ @DBFileName +''+ '2.bak'',
DISK = '''+@Path +''+ @DBFileName +''+ '3.bak'',
DISK = '''+@Path +''+ @DBFileName +''+ '4.bak'',
DISK = '''+@Path +''+ @DBFileName +''+ '5.bak'',
DISK = '''+@Path +''+ @DBFileName +''+ '6.bak'',
DISK = '''+@Path +''+ @DBFileName +''+ '7.bak'',
DISK = '''+@Path +''+ @DBFileName +''+ '8.bak'',
DISK = '''+@Path +''+ @DBFileName +''+ '9.bak'',
DISK = '''+@Path +''+ @DBFileName +''+ '10.bak'',
DISK = '''+@Path +''+ @DBFileName +''+ '11.bak'',
DISK = '''+@Path +''+ @DBFileName +''+ '12.bak'',
DISK = '''+@Path +''+ @DBFileName +''+ '13.bak''
WITH INIT , NOUNLOAD , NAME = ''DayNite Full Backup'', NOSKIP , NOFORMAT '
print @SQL
exec (@SQL)
Hope it Helps!!

Similar Messages

  • Backup failed with tar file write error (10054)

    Hi
    I have got the issue with the online backup.
    Database: Oracle 9.2.0.7
    SAP : 4.7
    Backup Server: Netbackp
    When ever i trigger the backup on few of my SAP Servers, it runs for a while and then at a point just get struck.
    Where for other systems it is running fine.
    Error:
    Incident:1
    http://80.00 18:52:28 INF - Waiting for mount of media id A00201 on server mk2sapp001-b.
    http://80.00 18:53:42 INF - Beginning backup on server mk2sapp001-b of client mk1sap01-b.
    http://80.00 18:55:10 FTL - tar file write error (10054)
    Incident:2
    http://80.00 12:05:50 BKR - G:\oracle\VWD\sapdata1\btabd_41\
    http://80.00 12:05:53 INF - Beginning backup on server mk2sapp001-b of client mk1sap01-b.
    http://80.00 12:08:13 FTL - tar file write error (10054)
    http://80.00 12:08:13 INF - Client completed sending data for backup
    After the step mentioned in bold it just get struck,
    There is no issue with the space at OS level
    I can see all process will still be running in task manager
    such as backint.exe, brbackup.exe, brconnect.exe
    But
    I don't find bpbkar32.exe Process, after the backup got struck.
    I have asked Network guys as well and they said every thing is fine from their side(such as Speed, Full Duplex)
    Its very important, please assist.
    Thanks in advance

    yes , i am using symantec netbackup,
    but every thing is fine from their side as well(settings).
    i have reinstalled the client as well.
    it runs for 1 hr and then it throws error.
    yesterday i scheduled two backup at two different time(at the interval of 1 hr) but they both failed (struck) at the exact same time(even seconds were same).
    So what do you say??

  • Generate Proxy from WSDL with multiple Files

    I need to load a WSDL (to generate a web service consumer proxy). However, that WSDL is build from multiple files, both .wsdl and .xsd, not a single one. It seems the SAP wizard to generate the proxy does expect one single WSDL file however.
    Is there a way in SAP to load a WSDL with multiple files, or do I need to (manually) flatten all these files into one single file?

    I am not sure why it fails in WebSphere. Please try posting
    this question to a WebSphere newsgroup.
    Regards,
    -manoj
    http://manojc.com
    "viswanath" <[email protected]> wrote in message
    news:40aee7fa$1@mktnews1...
    >
    thanks manoj for your reply.
    I'm using IBM WebSphere SDK for Web Services v5.1
    for generation of java client.
    I'm able to generate the client but the problem is
    the WSDl2Java command ignored the SOAPHeaders while
    generating the proxy. Since I'm using SOAP headers for
    authentication the code fails.
    Thanks,
    Viswanath
    "manoj cheenath" <[email protected]> wrote:
    I am not sure which tool you are using
    to generate web service clent. To generate
    a WLS web service client you have to use clientgen.
    Details here:
    http://e-docs.bea.com/wls/docs81/webserv/anttasks.html
    Regards,
    -manoj
    http://manojc.com
    "viswanath" <[email protected]> wrote in message
    news:40ad8a07$[email protected]..
    HI,
    I have a web service (implemented in .NET) which extends soap headersfor
    doing
    Authentication. WSDL is generated out of this web service. But wheni use
    wsdl2java
    (J2EE) to generate a proxy class, there is no interface generated forsoap
    headers.
    Without extending SOAP headers the web service works fine.
    Basically, I'm looking for a way to generate java interfaces (ie.
    proxies)
    for
    SOAP headers out of the WSDL file.
    PFA the WSDL file and the proxy
    Any help on this is appreciated.

  • Working with Multiple Files in Workspace Layout

    If I was working with multiple files in the workspace layout, they each used to be available for selection from a tab.  Now I can either cascade the files horizontally or vertically - but not have them appear in a tab across the top of the workspace layout.
    Does anyone know how to set the workspace to present multiple files in tabs?  I have CS3.

    Tanya,
    This may not help, but the times when that happens to me is when I go too fast and some operations haven't finished. I then try to select a file that hasn't completed and the file I select is in the process of having the data updated. The worst is when it is trying to render as I am doing something.
    I hope this helps some.
    Mel

  • Problem Creating PDF with Multiple Files in Pro. 7

    I'm using Adobe Acrobat Professional 7 on a computer with Windows XP.
    The problem is that when I try to create a PDF with multiple files everything just suddenly stops. There are 75 files involved and when it gets to around 41 or so (don't know the exact number because I turned away from my computer for just a moment), it just stops. There are no error messages; nothing. Just a blank Acrobat screen.
    Last week I had a different problem which was resolved by an uninstall/reinstall and I was able to create the PDF with those exact same 75 files, but after the PDF was created I realised that some changes needed to be made. I dumped the PDF, made the appropriate changes and left it for the weekend. Today I the new problem has arisen.
    Any ideas what the problem might be?

    I've read many discussions about Acrobat and problems with server files, with the general solution being what you are doing... copy the files to a local hard drive

  • Create folder with multiple files (was: folders)

    Can you create a folder with multiple files and direct the page to go to the folder and then the reader can select the file they wish to choose?  Example  Council Mintes Folder with a file for each set of minutes.  The hyperlink would open the folder and then the reader would select whch set of minutes they'd like to see.

    You may not have access to it depending on your hosting company and  plan, but if you did have the ability to change it you'd normally do it in the admin area of your hosting account which would update the proper files on your server.
    You may also be able to do it manually, but the "how to" depends on the server type you are running.
    EDIT: I'd still suggest using a server script (like the PHP I linked to) because the look of a directory with browsing turned on is pretty ugly and can't be changes since it's not a page on your site. With the PHP I linked to, you could have an actual page for your links, complete with your site's design, that simply lists the files from the specified directory. It's very simple to set up if you have PHP on your server.

  • How to send the mail with multiple file attachments ?

    Sending mails with multiple files as attachments.

    You need to start from the app, assuming that it has an email function, that contains the files that you want to send as attachments. The Photos app allows you to send up to 5 photos on the same email, but if you want to send multiple file types then you need an app that supports all those file types. I use the GoodReader app which supports quite a few document/file types (e.g. PDF, Excel, Word, pictures), and from that I can select multiple files (including different types) and attach them to the same email.

  • "Place into Photoshop" with multiple files

    I'd love to see this feature in Bridge
    Import multiple files into an existing photoshop file (with a predetermined size ) as smart object layers in photoshop.
    The options that Bridge currently offers falls short in 2 area
    Load Files into Photoshop Layers-- does not import smart objects and creates a new photoshop file that ends up being as large as the largest imported file
    Place into Photoshop--only lets you do one at a time
    I need "Place into Photoshop" with multiple files
    Is there a way to do this?
    Thanks!!

    I agree, placing multiple files into your PSD as smart objects all at once like InDesign would be a great (and logical) feature for Photoshop to have. The only "workaround" I have is to create a shortcut using Ctrt+Alt+Shift+D (which is not used by anything), so you can place pictures/graphics more quickly, rather than using the menu each time.

  • Pull a zip file with multiple files unzip it, and finally load one of the f

    Hi Aill,
    I have following query.
    Could we do the following with XI: pull a zip file with multiple files from a vendor which resides outside of XI server network, unzip it, and finally load one of the files to SAP?
    Regards
    Rohan S

    Hi Varadharajan,
    I have 10 text files in some ZIP file on one server which is out side of network. We can reach that file through Proxy only to read ZIP file.
    I need to extract the file and on the bases of some condition one of the file i need to upload data to SAP.
    Is it possible. If possible then How?
    Regards

  • Ifconfig pcelx0 plumb fails with Bad file number error

    Hi,
    I installed solaris 8 (x86) on a Toshiba Tecra 8000.
    The Tecra uses Neomagic NM2200 chipset for it's display.
    Even though it is not supported by the Sun Drivers, getting xfree86 for sun fixed the display problem for me.
    Now according to the various sources that guided me in this task seemed to point at a few things that I had to do in order to make the Tecra work okay with Solaris 8 :
    1)Change the PCMCIA mode in the BIOS from automatic to PCIC mode
    2)Make sure that there were no IRQ conflicts on the system.
    3)Install the OS.
    Once the OS was installed, I ran prtconf -D and saw that the network instance #0 pcelx0 was showing up under pcic.
    I did not have to install the xig init-pcic patch.
    But it did not create an entry in /devices or /dev (as a link) with the error
    "pcelx0 requested IRQ failed 6".
    Also, I suppose that is the reason why when pcelx0 is plumbed, it comes out with the error message:
    ifconfig pcelx0 plumb : "bad file number"
    Any help will be greatly appreciated.
    Thanks,
    Dwai.

    Thanks Alex,
    I found out -
    ifconfig adapter plumb will fail with Bad File number error when the device file that is being referred to is missing.
    I checked and found that the pcelx link is not being made in the /dev directory and the file not created in /devices.
    I also found that when /reconfigure is run, it tries to create the device for pcelx but fails with this eror message:
    pcelx : RequestIRQ fail 6
    I am assuming that there is some IRQ conflict with some other device.
    Thanks,
    Dwai.

  • SQL*Loader with multiple files

    Gurus,
    I search the documentation and this forum and haven't found a solution to my issue yet...
    I am not expert of SQL*Loader. I have used SQL*Loader to copy from one file to a table many times. But I have not copied multiple files into one table especially with different names.
    More specifically....
    I need to load data from multiple files into a table. But the file names will be different each time. A file will be created every hour. The file name will consist of the root file name appended by a time stamp. For example, a file created on 10/07/2010 at 2:15 P.M. would be filea100720101415.txt while a file created on 10/08/2010 at 8:15 A.M. would be filea100820100815.txt. All the files will be in one directory.How can I load the data from the files using SQL*Loader?
    My database: Oracle 10g Release 2
    Operating System: Windows 2003 Server
    Please assist.
    Robert

    sect55 wrote:
    Gurus,
    I search the documentation and this forum and haven't found a solution to my issue yet...
    I am not expert of SQL*Loader. I have used SQL*Loader to copy from one file to a table many times. But I have not copied multiple files into one table especially with different names.
    More specifically....
    I need to load data from multiple files into a table. But the file names will be different each time. A file will be created every hour. The file name will consist of the root file name appended by a time stamp. For example, a file created on 10/07/2010 at 2:15 P.M. would be filea100720101415.txt while a file created on 10/08/2010 at 8:15 A.M. would be filea100820100815.txt. All the files will be in one directory.How can I load the data from the files using SQL*Loader?
    My database: Oracle 10g Release 2
    Operating System: Windows 2003 Server
    Please assist.
    RobertToo bad this isn't in *nix, where you get a powerful shell scripting capability. 
    That said, here is the core of the solution .... you will also need a way to identify files that have been processed vs. new ones. Maybe rename them, maybe move them. But with this sample you can see the basics. From there it is really an issue of DOS scripting, which would better be found by googling around a bit.
    cd c:\loadfiles
    FOR %%datfile IN (*.txt) DO SQLLDR CONTROL=sample.ctl, LOG=sample.log, BAD=baz.bad, DATA=%%datfileTry googling "dos scripting language". You'll find lots of tutorials and ideas on "advanced" (well, as advanced as DOS gets) techniques to solve your problem.
    Edited by: EdStevens on Dec 1, 2010 5:03 PM

  • Backup/restore database with dump file

    Hi everybody,
    I would like to backup/restore my database with Oracle Utility commands(exp/imp) but I can only execute these commands in the machine where database server is being installed. When I use Oracle client to connect to DB server to execute these commands, DB server can not understand these commands.
    Is there any method to do this?
    Please help me.

    My workout for you is as follows (assuming, you configured tnsnames pointing to the listener concern with your database)...
    SQL> select * from example;
    ITEM STORE STARTDATE ENDDATE
    1 10 01-JAN-06 19-JAN-06
    1 10 03-JAN-06 20-JAN-06
    1 10 01-FEB-06 20-FEB-06
    2 10 01-JAN-06 15-JAN-06
    SQL>
    C:\>exp scott/[email protected] tables=example query=\"where item=1\" file=example.dmp
    Export: Release 9.2.0.1.0 - Production on Fri Dec 15 08:06:16 2006
    Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
    Connected to: Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
    With the Partitioning, OLAP and Oracle Data Mining options
    JServer Release 9.2.0.1.0 - Production
    Export done in WE8MSWIN1252 character set and AL16UTF16 NCHAR character set
    server uses US7ASCII character set (possible charset conversion)
    About to export specified tables via Conventional Path ...
    . . exporting table EXAMPLE 3 rows exported
    Export terminated successfully without warnings.
    C:\>
    -aijaz

  • Comparing PL/SQL code from different database

    Hi,
    I have 3 databases(development, test and production) lying in 3 different servers. I wanted to check if all the databases have the same PL/SQL code.
    is there a automatic ways of doing that. If not is there any best practices that can be followed
    I use oracle 10g
    Thanks,
    DJ

    Dont you have a Change Management System in place. How do you do your deployment. What is the versoin control system you use?
    When you deploy your code in some database dont you store the details some where?
    In database source code is available at ALL_SOURCE. You can query that and compare. But its never a good idea.

  • Problem with multiple file download

    Good day.
    I have a code that downloads multiple files from the database and then saves it to a specified directory. I work fine but when I check the contents of the file, some of them are not complete. Lets, say I have downloaded 16 files and only file # 4,5,6,7 have the correct contents as compared to the original.
    Why is that so?
    my code snippet:
    DiskFileUpload fu = new DiskFileUpload();
              fu.setSizeMax(1000000000);
              List fileItems = fu.parseRequest(request);
             Iterator itr = fileItems.iterator();
              while(itr.hasNext())
              FileItem fi = (FileItem)itr.next();
              if(!fi.isFormField())
                     String filen = fi.getName();
                     String fname = filen.substring(filen.lastIndexOf(java.io.File.separator)+1);
                   Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
                   connection = DriverManager.getConnection(connectionURL, "", "");
                   statement = connection.createStatement();
                   String sql = "INSERT INTO tblTestFiles("
                                    + "strFileName,"
                                    + "imgFile) "
                                    + "VALUES(?,?)";
                 PreparedStatement pstmt = connection.prepareStatement(sql);
                   //Set the values for strFileName and imgFile
                   pstmt.setString(1,fname);
                   // Set the blob
                   //File file = new File(fnew);
                 FileInputStream is = new FileInputStream(filen);
                 pstmt.setBinaryStream(2, is, (int)filen.length());
                     // Insert the row
                 pstmt.executeUpdate();I am using eclipse 5.5.23, eclipse 3.2 with myeclipse SDK, MS SQL, Ant.

    sorry I posted the wrong code. here's the correct one:
    statement = connection.createStatement();
            rs = statement.executeQuery("SELECT strFileName,imgFile FROM tblTestFiles ORDER BY strFileName");
            while (rs.next())
                   String filename = rs.getString(1);
                Blob blob = rs.getBlob(2);
                   InputStream is = null;
                   is = blob.getBinaryStream();
                   int i;
                   String dir = "C:\\DownloadedFiles";
                   File path = new File(dir, filename);
                   FileOutputStream fos = null;
                   fos = new FileOutputStream(path, true);
                   PrintWriter pout = null;
                   pout = new PrintWriter(new FileOutputStream(path,true));
                   while ((i = is.read()) != -1)
                      pout.write(i);
                   fos.close();
                   pout.close();
             }// end of if construct
        }// end of try
         catch (IOException e)
             e.getMessage (); e.printStackTrace();
              System.out.println(e);
        catch (SQLException e)
             e.getMessage (); e.printStackTrace();
              System.out.println(e);
        }Thanks.

  • Size limit of access database with image files stored outside database

    I have read 2GB limit on size of Access database.  We are using Access 2013 database with fields that are data type attachment and storing attached images outside the database.  Does the size of the folder that is holding these images count
    in any way toward 2GB size limit?

    Hi,
    As far as I know, Access database limit size 2GB based on itself, not related to the folder size.  Attachment data
    type is similar to attaching files to e-mail messages. We need to control the Access database size is smaller then 2GB.
    When a field is defined with the attachment data type, you can store one or more files for each record in it.
    Attachments can dramatically increase the size of the database, but since the attached file is stored as a part of the dabatbase, you are not dependent on network drives being available as you would be if you inculded a hyperlink to the file. As a matter of
    fact, feel free to backup the origainal file to other disk after you attach it to the database.
    Regards,
    George Zhao
    TechNet Community Support

Maybe you are looking for

  • How to use DataSource and External transaction in 9ias?

    I'm working on a project that the application server needs to connect to over 100 databases. I'd like to use connection pooling and external transaction service defined in OC4J's Datasources. I wonder if anyone has an example of using datasource and

  • In ios 7, how do I get the calendar to open each time in list mode?

    In ios 7, on the iphone 5, how do I get the calendar to open each time in list mode? It always opens is strange new mode and goes to list mode only if I click the search icon.

  • LCM utility taking more time to start

    Hi All, In Hyperion System 9.3.1 when running the LCMUtility.bat file in Hyperion Home\BIPLUS\bin folder it is taking nearly 8-10 minutes to start up the process. The shared services, IR, Core services are in the single box. Even though it is taking

  • Creating non-default Fonts in JDK 1.1

    Hello, I need to create an applet that runs on 1.1 and has access to as many fonts as possible. Are there any ways that I can create other Fonts in JDK 1.1 except for the ones returned by Toolkit.getFontList()? Thanks for your help.

  • It's... gone?

    Okay, here's the thing... Every piece of music from my iPod has completely vanished without a trace, I have no idea what happened to it... Only the non-musical bits of data I had on it remain. Would anyone know either what caused this, or how to fix