Add check database exist in script from Power Designer
In most part of my projects, I am using Sybase Power Designer for build and support model and scripts of a database. So, this is a useful tool that allows quickly and easy to do all necessary function with script. In my current project – Tasker, I needed to create installer to install Server side of this software. To do this I need to generate database script from the model to provide for the installer.
When I opened my project file with the model, then go to the physical model, then click on Database menu and generate database script …
Yes, we have finished first part of what we need. To add checking for exist database you need to click on menu Tools->Resources-> DBMS…

The next step would be edit template for drop database related to your current DBMS. In my case this is MS SQL 2008. Select Script->Objects->Database and Drop. All that you need is edit value of a template for dropping operation for this:
USE [master] IF EXISTS (SELECT name FROM sys.databases WHERE name = N'%DATABASE%') BEGIN EXEC msdb.dbo.sp_delete_database_backuphistory @database_name = N'%DATABASE%' ALTER DATABASE %DATABASE% SET SINGLE_USER WITH ROLLBACK IMMEDIATE ALTER DATABASE %DATABASE% SET SINGLE_USER DROP DATABASE %DATABASE% END
- Комментировать (войти)





