0

I would like to create a T-sql script and scheduled. My goal is create all my databases (4 databases) and when the QA or DEV team need to test something, they can use these databases. The problem is that I don´t have other server so I have to use the same server, for example I have a database called AUXDB, so I need to create a new database as PRE_AUXDB. I have been creating all the scripts per each dabatase (just structure) but I need to know, how to create a header script to execute each script. I hope you can understand my request.

Thank you in advance. Raúl

4
  • Sorry, it is not very clear what you want. If you need to create DBs for test you can use all scripts that you have, just set the name of the test DB inside each of them. Also what do you mean by "schedule"? You need to create that DBs every day? Jul 21, 2015 at 8:48
  • Hi, I will try to explain it in a better way. For example: DEV team want to test a new development so I would like to have a job that delete all the PRE-% databases and re-build again the PRE-% databases and then fill in all these databases with two months of historic data from PROD environment. I have to do it in this way because I have to use the same server so I will have a database AUXDB where DEV team develop and PRE-AUXDB where must to have the same structure but with PROD data. Jul 21, 2015 at 9:08
  • It is still unclear why you need to schedule this. Is this something that is going to be executed at well defined time intervals? If so, how often exactly? It may not matter for the solution, but I'm trying to understand what you are trying to accomplish, in case maybe you don't really need any scheduling for this, just a script that would be run on demand perhaps.
    – Andriy M
    Jul 21, 2015 at 9:41
  • Hi Andriy, Well this script would be run on demand but it can be twice per week, or more that´s why I want to have something automatic and when DEV team want something, just I want to run this job or script and they can have "QA environment" updated with DEV Env. The problem is that I donçt have other server for QA so I need to use DEV server copying the databases and rename it as PRE_%. Jul 21, 2015 at 10:40

1 Answer 1

0

Ok, after yor comment it is clear. I will do the following:

  1. Create a new DB called SERVICE, MAINTANANCE, etc.
  2. Inside it create a stored procedures for different steps - drop old DB, create new DB, populate new DB. You can make all that in one procedure also.
  3. Create one procedure which will execute others - step by step (if you not implemented all logic in one procedure).
  4. Creata a job with permissions - inside it strat main procedure. Or tell DEV team to use main procedure inside new DB (with appropriate permissions).
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.