Ask a Question

SQL Database Validation

mnichola30
Occasional Contributor

SQL Database Validation

The sofware that I'm testing creates a new SQL database with a unique name everytime the software is run.  I would like to create a script that validates the tables within each new database.  Is it possible to validate a database with a dynmic name? 



Thanks,



Melissa
3 REPLIES 3
karkadil
Valued Contributor

The following code will list all existing databases on the server



//[JScript]

function Test1()

{

  var cmd = ADO.CreateADOCommand();

  cmd.ConnectionString = "Provider=SQLOLEDB.1;Data Source=MY-PC\\SQLEXPRESS;user id=MY_LOGIN;pwd=MY_PASSWORD;Integrated Security=SSPI;";

  cmd.CommandText = "EXEC sp_databases";

  cmd.CommandType = cmdText;

  var rs = cmd.Execute();

  rs.MoveFirst();

  while(!rs.EOF)

  {

    Log.Message(rs.Fields("DATABASE_NAME").Value);

    rs.MoveNext();

  }



}



All you need to do is to get a list of all databases before your application create a new one, then once again after it and compare results 🙂

The difference will be a new created database.



And you need to use a correct command line to your server, of course

Hi all,


We are also planning to publish a similar script in the How To section of our Support Portal.


Best regards,
Alexey

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️

Hi,


We've published a similar script here:

http://www.automatedqa.com/support/viewarticle.aspx?aid=17636


Best regards,
Alexey

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
cancel
Showing results for 
Search instead for 
Did you mean: