• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 484
  • Last Modified:

Need to backup a database to my machine from host to my machine script.

I have a database that resides on 72.18.146.251,1533 (SQL Server - dbkore)

I would like to backup the database onto SM3-93-BILL2(SQL Server - sa)

The name of the databasae is DK-DOTNET.

I would  like to just be able to run a script whenever.

Thanks guys.
0
mathieu_cupryk
Asked:
mathieu_cupryk
  • 16
  • 8
  • 3
  • +1
1 Solution
 
MohammedUCommented:
Open the query window from  SM3-93-BILL2 and connect to 72.18.146.251,1533 (SQL Server - dbkore) Server and run the following script...

backup database <dbname> to disk = 'path and filename'
with init
OR
Open the query window on 72.18.146.251,1533 server and connect to 72.18.146.251,1533 server
run the following script...
backup database <dbname> to disk = '\\SM3-93-BILL2\...\filename.bak'
with init
0
 
mathieu_cuprykAuthor Commented:
is there a script file I can run
0
 
MohammedUCommented:
what do you mean by script file?

I posted the script and you can use it with your convinient...
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
mathieu_cuprykAuthor Commented:
no ssis?
0
 
ErnariashCommented:
You can create a batch file using osql utilities...then automate the processes.
YouBackup.bat

osql -S dbkore -U sa -P pass -Q " BACKUP DATABASE DK-DOTNET TO DISK = '\\SM3-93-BILL2\c$\DK_DOTNET.bak' " 

Open in new window

0
 
MohammedUCommented:
You can also use SQLCMD....instead of OSQL...
0
 
mathieu_cuprykAuthor Commented:
I want to copy the contents of the tables from one database to another tables
backup up. Not put it in a backup file.
0
 
HoggZillaCommented:
So, in SSIS, you want to backup a database, all of it's tables, to another database. How about views, stored procedures and functions? Users? Or just the tables and data.
0
 
ErnariashCommented:
Since your are using SQL Server 2005  please use SQLCMD is the new  verssion. OSQL and SQLCMD are functionaly equivalent see link
 

SQLCMD  -S dbkore -U sa -P pass -Q " BACKUP DATABASE DK-DOTNET TO DISK = '\\SM3-93-BILL2\c$\DK_DOTNET.bak' " 
 

Open in new window

0
 
mathieu_cuprykAuthor Commented:
just tables and data

I have a host server with database name dk-dotnet
I have on my machine a database with the same name dk-dotnet
I want to transfer the information from host to my machine
0
 
HoggZillaCommented:
If the table did not change, then you could easily create an SSIS package to do this. Can you expect the tables might change or new tables will be added? And, if this is the case, you want the SSIS package to dynamically backup all tables?
0
 
mathieu_cuprykAuthor Commented:
The tables will not change.
An SSIS package would be cool. I am not really familar but I have to start learning SSIS.
0
 
HoggZillaCommented:
In SQL Server Management Studio you can click on the database you want to Backup and select Tasks, Export Data. Then you follow the wizard to copy all of the tables to your Destination database. If the tables are not there, it will create the tables in a script. When you get to the end, choose the option to save as an SSIS Package. Next, we will open Integration Services in Visual Studio and edit the package so it can run as a scheduled job.
0
 
mathieu_cuprykAuthor Commented:
do I do a copy data  or a write query
0
 
mathieu_cuprykAuthor Commented:
Hogg,
Do I save this as a file system or sql server
0
 
HoggZillaCommented:
Save to File System
Copy Tables - Not Query
 
0
 
mathieu_cuprykAuthor Commented:
encrypt data sensitive data with user key.
0
 
mathieu_cuprykAuthor Commented:
or do not save sensive data?

which one do i use hogg.
0
 
HoggZillaCommented:
If you connect to SQL Server with Windows Authentication then it really does not matter. But just to be save, choose Do Not Save
0
 
mathieu_cuprykAuthor Commented:
C:\Documents and Settings\mcupryk\My Documents\Copy.dtsx

ok what should i do now?
0
 
HoggZillaCommented:
To open SSIS, go to SQL Server 2005 on the Start Menu. Choose Visual Studio Business Intelligence Development Studio.
Create a New Project, Integration Services.
In the Solution Explorer, Right Click and Add existing package. Choose File System and go grab your saved package. Open it up and you are now editing the SSIS Package.
0
 
mathieu_cuprykAuthor Commented:
I deleted all the tables in the destination db
I get the following:
==================================

Could not connect destination component.

Error 0xc0202009: Destination - tbl_dotnet_attachments [31]: An OLE DB error has occurred. Error code: 0x80040E37.
An OLE DB record is available.  Source: "Microsoft SQL Native Client"  Hresult: 0x80040E37  Description: "Invalid object name 'DK-DOTNET.dbo.tbl_dotnet_attachments'.".


Error 0xc0202040: Destination - tbl_dotnet_attachments [31]: Failed to open a fastload rowset for "[DK-DOTNET].[dbo].[tbl_dotnet_attachments]". Check that the object exists in the database.
 (SQL Server Import and Export Wizard)

===================================

Exception from HRESULT: 0xC0202040 (Microsoft.SqlServer.DTSPipelineWrap)

------------------------------
Program Location:

   at Microsoft.SqlServer.Dts.Pipeline.Wrapper.CManagedComponentWrapperClass.ReinitializeMetaData()
   at Microsoft.SqlServer.Dts.DtsWizard.Execute.GenerateOleDbDestinationColumns(TransformInfo ti, IDTSDesigntimeComponent90 comp)
   at Microsoft.SqlServer.Dts.DtsWizard.Execute.SetDestConnection(Exception& ex, TransformInfo ti)

0
 
mathieu_cuprykAuthor Commented:
- Validating (Error)
Messages
Error 0xc0202049: Data Flow Task: Failure inserting into the read-only column "AttachmentID".
 (SQL Server Import and Export Wizard)
 
Error 0xc0202045: Data Flow Task: Column metadata validation failed.
 (SQL Server Import and Export Wizard)
 
Error 0xc004706b: Data Flow Task: "component "Destination - tbl_dotnet_attachments" (31)" failed validation and returned validation status "VS_ISBROKEN".
 (SQL Server Import and Export Wizard)
 
Error 0xc004700c: Data Flow Task: One or more component failed validation.
 (SQL Server Import and Export Wizard)

0
 
mathieu_cuprykAuthor Commented:
USE [DK-DOTNET]
GO
/****** Object:  Table [dbo].[tbl_dotnet_interviews]    Script Date: 11/17/2008 15:52:41 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[tbl_dotnet_types](
      [TypeID] [int] NOT NULL,
      [CategoryID] [int] NULL,
      [Name] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
      [Description] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
) ON [PRIMARY]

GO
CREATE TABLE [dbo].[tbl_dotnet_user](
      [userID] [int] IDENTITY(999,1) NOT NULL,
      [szUserName] [varchar](15) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
      [szPassword] [varchar](15) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
      [szName] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
) ON [PRIMARY]

GO
CREATE TABLE [dbo].[tbl_dotnet_interviews](
      [InterviewID] [int] IDENTITY(1,1) NOT NULL,
      [DateCreated] [datetime] NULL,
      [DateLastModified] [datetime] NULL,
      [UserID] [int] NULL,
      [AppID] [int] NULL,
      [BrowserID] [int] NULL,
      [OsID] [int] NULL,
      [PrimaryUse] [nvarchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
      [Issues] [nvarchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
      [MajorChanges] [nvarchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
      [Training] [nvarchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
      [OtherApp] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
      [OtherBrowser] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
      [OtherOs] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
      [szName] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
) ON [PRIMARY]

GO
CREATE TABLE [dbo].[tbl_dotnet_attachments](
      [AttachmentID] [int] IDENTITY(1,1) NOT NULL,
      [InterviewID] [int] NULL,
      [Filename] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
      [ImageContent] [image] NULL,
      [DateCreated] [datetime] NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

SET ANSI_PADDING OFF
0
 
HoggZillaCommented:
Here is my document on Getting Started with SSIS. Post your package here if you want me to take a look. You should open each of your Connection Managers and Test the Connection. You may also need to save the package with a ProtectionLevel of Encrypt with User Key. You can do this by setting the property for the Package.
SSIS-Getting-Started.doc
0
 
mathieu_cuprykAuthor Commented:
ok I got it I had to check the identities in each table what should I do next.
0
 
HoggZillaCommented:
In your SSIS Package you have the Create Table statements, but on a regular basis you may want to just Truncate these tables, not Drop and Recreate them. So modify your Preparation SQL accordingly, to Truncate or Drop & Recreate. Then, you probably should remove the Identity columns from this backup database so you can insert the numbers as they exist in the Source database. But just so I mention, you might be able to do this anyway just by enabling Identity inserts. Does this help?
0
 
mathieu_cuprykAuthor Commented:
This is good thought. But I did not know I would have to remove identity columns,
This is more work.
0
 
mathieu_cuprykAuthor Commented:
hogg I need to buy maybe a book on this to integrate with visual studio?
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 16
  • 8
  • 3
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now