11-30-2011 04:25 AM
I am designing a "universal" test system for a variety of my company's products.
The test results are supposed to be logged to a MS SQL (2008) database. I've created two databases for two different products. Let's call them OneTestDB and TwoTestDB for now.
No problems so far. Now, I want to use a user, TestLogin, to write the test data to the both of my databases, however, TestLogin can seems only to be able to write to the DB set as default.
I could solve the problem by using different users, but since I want it to be possible for the same user to test different products, I would prefer to avoid this.
After searching the net for an answer I found that that what I'm trying to do is done by the query "EXEC sp_defaultdb 'USER', 'DATABASE'. (Would USE {DATABASE} work as well?)
The database name is given at runtime. (DATABASE = StationGlobals.ProductName + "TestDB")
Here is my question: how , and where, to put that code into Teststand (2010 SP1) so that I can change the database to which I want to save the test results?
I have been trying to use the database tools given in Teststand, but obviously I am not doing it the right way.
Solved! Go to Solution.
11-30-2011 07:54 AM
I managed to fix it myself.
The solution was the following SQL statement "EXEC sp_defaultdb 'TestLogin', '" + StationGlobals.ProductName + "TestDB'"
If someone has a better idea how to solve the issue, feel free to enlighten me.