问题
In SSIS 2008, is there is way to design an SSIS package around the problem when an OLE DB data source returns an error like this "Database [xyz] cannot be opened. It is in the middle of restore."?
I am hoping there is a way to design a loop into an SSIS 2008 package to trap this error, maybe wait 5 or 10 minutes for the source DB to finish restoring (from log shipping for example) and then try again - with a max retry limit built in.
Thank You.
回答1:
Yes. When you connect, don't connect to your database. Use master, say, in a different connection object.
Then, query the state column in sys.databases. If not 0, wait for a bit, try again.
来源:https://stackoverflow.com/questions/5236712/ssis-database-xyz-cannot-be-opened-it-is-in-the-middle-of-a-restore