Thursday, March 22, 2012
Can I copy database files without dismounting them
from a different location.
I want to maintain two identical copies.
Thanks.Hello!
Yes, of course you can do that by using BACKUP \ RESTORE.
Back up your database and restore it on the other instance or SQL Server.
You may get more information about BACKUP and RESTORE from the following
address:
http://msdn2.microsoft.com/en-us/library/ms187048.aspx
--
Ekrem Önsoy
<war_wheelan@.yahoo.com> wrote in message
news:1189434972.953100.269150@.r34g2000hsd.googlegroups.com...
> Can I copy database files without dismounting them and attach them
> from a different location.
> I want to maintain two identical copies.
> Thanks.
>|||Why can't I copy the db files (mdf/ldf) to a new location without
detaching the database?
Why won't this work?
On Sep 10, 11:25 am, Ekrem =D6nsoy <ek...@.btegitim.com> wrote:
> Hello!
> Yes, of course you can do that by using BACKUP \ RESTORE.
> Back up your database and restore it on the other instance or SQL Server.
> You may get more information about BACKUP and RESTORE from the following
> address:http://msdn2.microsoft.com/en-us/library/ms187048.aspx
> --
> Ekrem =D6nsoy
> <war_whee...@.yahoo.com> wrote in message
> news:1189434972.953100.269150@.r34g2000hsd.googlegroups.com...
> > Can I copy database files without dismounting them and attach them
> > from a different location.
> > I want to maintain two identical copies.
> > Thanks.|||Because attaching is only guaranteed if you have a consistent state of the database, which is what
you get by detaching it.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
<war_wheelan@.yahoo.com> wrote in message
news:1189527362.768605.200480@.w3g2000hsg.googlegroups.com...
Why can't I copy the db files (mdf/ldf) to a new location without
detaching the database?
Why won't this work?
On Sep 10, 11:25 am, Ekrem Önsoy <ek...@.btegitim.com> wrote:
> Hello!
> Yes, of course you can do that by using BACKUP \ RESTORE.
> Back up your database and restore it on the other instance or SQL Server.
> You may get more information about BACKUP and RESTORE from the following
> address:http://msdn2.microsoft.com/en-us/library/ms187048.aspx
> --
> Ekrem Önsoy
> <war_whee...@.yahoo.com> wrote in message
> news:1189434972.953100.269150@.r34g2000hsd.googlegroups.com...
> > Can I copy database files without dismounting them and attach them
> > from a different location.
> > I want to maintain two identical copies.
> > Thanks.sql
Tuesday, March 20, 2012
Can I copy a DTS Package?
9 db tables populated by 9 Excel Import Files via DTS.
Will I need to create a DTS package for each import? Columns are identical in all 9 - the only thing different is the destination table name and source file name.
I've had to map over 80 columns using DTS and don't want to do it for each instance!
Any help would be appreciated..1. Rightclick the DTS-package in Enterprise Manager
2. Choose "design package"
3. Make the changes you want
4. Go to menuitem "Package" and choose "Save as"
5. You now have a copy of your DTS-package|||Nice one! Cheers.|||This is not the best way -
Dude - create a table in the destination db called tblFileSource that has:
ID, SourceFile, DestinationTable, importDate
Define FileSource and DestinationTable as Global Variables in the package.
Then, the first step of you package use a Execute SQL task that will set you global Varaiables to the result of
select top 1 SourceFile, DestinationTable
from tblFileSource
where importDate is null
Then, use a Dynamic Properties Task to change the source and destination in the Data Transformation Step.
Then, after the Transformation, do another Execute SQL Task (on Success):
Update tblFileSource
Set importDate = getDate()
where SourceFile = ?
Where the ? is the global Variable FileSource.
Isn't this a more professional method - comes in handy when the number of files increases.
Can I call a web service from SQL?
I have two databases with two identical tables in seperate physical locations. I want database B tables to be updated automatically when database A tables change. Is there a way to call a web service from SQL to make this happen? Or is there a better way to do this? I would really like it to get the rows that were modified and then copy only those rows to the other database tables. If anyone knows if this can be done please let me know. Thank you.
Why do you need a webservice? Maybe it's better to archieve this using UPDATE Triggers? Although the performance of firing triggers is not so good in some case, but it should be easier and faster than calling webservice. So let's say you want to trace modification made in database1.dbo.Table1, and you want to copy the modified rows into database2.dbo.Table2, and the 2 tables have almost the same structure, except the Table2 has 1 more column used to record UPDATETIME. You can create an UPDATE/INSERT trigger on Table1 like this:
CREATE TRIGGER trg_TraceMod ON tempdb.dbo.tbl_Const1 FOR UPDATE
AS
IF(object_id('tempdb.dbo.tbl_Trace') IS NULL)
BEGIN
SELECT deleted.*,GETDATE() AS UpdTime INTO tempdb.dbo.tbl_Trace FROM deleted
END
ELSE
INSERT INTO tempdb.dbo.tbl_Trace
SELECT deleted.*,GETDATE() FROM deleted
go
To learn more about triggers, you can refer to:
Enforcing Business Rules with Triggers
|||Thank you very much for the reply. The reason I was think about a webservice is because the two databases are in two different physical locations and cannot access each other without a web service because they are not on the same network. Basically one database is in our office and the other one in downtown in a data center. The one in the data center needs to update the one in our office everytime it changes. Could I use triggers to do that?|||Then you can tryLinked Servers. Connections between internet SQL Servers may be more complex than in the same network, there may be trouble in locating host SQL box, passing credentials, firewalls, and so on. You may take a look at this post if you fail to establish connections between the 2 SQL servers:
http://forums.asp.net/thread/1289341.aspx
And after the Linked Servers have been created (you can do this in Enterprise Manager->Security->Linked Servers), you can query the tables on the linked server using four part object name:
server.database.owner_name.object_name
Or you can useOPENQUERY.
|||My question is somewhat related. I need to call a web service upon completion of a sql job. Is this possible? I'm using a product called Captaris Workflow. What I need to do is call a web service that creates a new workflow process and emails the person responsible for the first workflow task. The workflow part may sound foreign, nevertheless, I want to call a web service when a sql job completes. Any help would be much appreciated.
Thanks,
Jason