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.
mathieu_cuprykAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
mathieu_cuprykAuthor Commented:
is there a script file I can run
MohammedUCommented:
what do you mean by script file?

I posted the script and you can use it with your convinient...
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

mathieu_cuprykAuthor Commented:
no ssis?
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

MohammedUCommented:
You can also use SQLCMD....instead of OSQL...
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.
Steve HoggITCommented:
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.
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

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
Steve HoggITCommented:
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?
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.
Steve HoggITCommented:
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.
mathieu_cuprykAuthor Commented:
do I do a copy data  or a write query
mathieu_cuprykAuthor Commented:
Hogg,
Do I save this as a file system or sql server
Steve HoggITCommented:
Save to File System
Copy Tables - Not Query
 
mathieu_cuprykAuthor Commented:
encrypt data sensitive data with user key.
mathieu_cuprykAuthor Commented:
or do not save sensive data?

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

ok what should i do now?
Steve HoggITCommented:
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.
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)

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)

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
Steve HoggITCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mathieu_cuprykAuthor Commented:
ok I got it I had to check the identities in each table what should I do next.
Steve HoggITCommented:
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?
mathieu_cuprykAuthor Commented:
This is good thought. But I did not know I would have to remove identity columns,
This is more work.
mathieu_cuprykAuthor Commented:
hogg I need to buy maybe a book on this to integrate with visual studio?
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.