How to help QA team access the right database? - sql-server

In the place I work, very often it happens that a developer and QA session goes like this:
(This is in reference to SQL Server 2005)
QA: I get Invalid object name 'customers'
DEV: huh? can u send me the exact SQL statement you used?
QA: select * from customers
DEV: hmm. (after some thinks) Are you sure you're using CUSTDB?
QA: yes
DEV: (after figuring out that QA was using CUSTDB_PRODUCTION) Please add "USE CUSTDB" and then tell me what you get with that SQL.
QA: Oh, sorry, I was using wrong DB.
The tab-text for the SQL window shows the information of which database the query is running on, but how do you ensure that QA follows this?
I will admit that I have made this mistake of using the wrong DB many times. I don't tend to read the text in the tab.
What are your experiences with this type of scenario? Have you found a way to help mitigate such a problem?

if your QA is using SSMS for testing you should try the window coloring options in SSMS Tools Pack free add-in for SSMS. this way you could immediately differentiate between servers.
if that's not an option don't allow QA to access production server at all. they shouldn't be able to anyway.

I think you need to formalise how QA will report an error.
You need to specify a set of information that they'll supply with every error report, including:
what they were doing (exactly)
their configuration (including the database!)
time/date (so you can match stuff in logs)
how to repeat it (if repeatable)
etc. You can act on that immediately, or log it in an incident tracking system and come back to it later (in which case the above is invaluable, otherwise it's all lost).
The above can be as simple as an email draft/template. But you need to be rigorous about this, otherwise (as you've discovered) you're going to go round in circles, perhaps without all the salient information you require.

If QA are allowed access to both live and dev databases, using SSMS, then there must be some level of accepted responsibility on their part and/or some level of training of them on your part.
They have been given a tool that allows them to ask questions of the data, but are asking the wrong questions, then complaining to you - if I was the DBA, I'd simply remove their access until they could demonstrate they knew what they where doing! I sympathise that that might not go down to well, but at least threatening to do it might make them think a little for themselves.
Think of this question as 'someone is doing something wrong'
There are 2 simple answers:
remove their ability to 'do something wrong'
train them to do it right
On the same note as Mladen Prajdic, you can colour code query windows in SQL2008 SSMS too.

Personally I use the fully qualified name in all queries (server.datatabase.owner.table - well I only use server if I'm deliberately using a linked server) because I move from database to database so much. If you specify the database in the queries to be run, they still work if connected to a differnt database on the same server or if you have a linked server. Have your QA adopt doing this as their standard if they are writing their own queries; if you are writing the test queries then you should be specifying the database name in the query not through a use statment.

Related

How not to mess up a customers SQL database?

Next week I will create some simple select queries for PowerBI for a new customer who wants to have more insight in his business.
Until now I have only done this for our own company. I am afraid that by installing SQL Server Management Studio and building some queries in Management Studio I might (in a freak accident scenario) damage his database. I know this is unlikely.
However I do not really want to mess with his configuration. I also do not want to give him any ground to argument against me if anything unrelated does not work afterwards.
What would be a reasonable way to get my queries without really touching his database ? I thought of using a 3rd party frontend like Heidi SQL or FlySpeed SQL (even better because you cannot do admin tasks with it). I cannot just start with PowerBI because I need to analyze his DB first (scroll through tables etc).
Also I thought of making a backup of his DB first but that involves playing around with Management Studio.
Thanks in advance for any suggestions!
Backup and restore. Then use the backup to work as a development system that way you can work out the bugs then put your app or queries into production.
Check out SSMS ToolsPack. It wont stop you from updating/deleting some rows. But will give you a warning if you are running a update/delete without a where clause. Or if you run a TRUNCATE or DROP TABLE statement. See config for settings. Also has color coding for windows.
Also has Window connection coloring - you can color the query windows based on the server/database name

Write Conflict in Access using SQL Server

There are other question on this site that do go pretty close to what I'm about to ask, but mine is slightly different (if anyone knows of a question that exists that covers this problem exactly, then please guide me to it).
I have Windows Server 2003 which has SQL Server 2000 (I think) on it. On that SQL Server, I have 5 databases, four of which I currently use. Now, I also have a laptop(win xp pro) which has a copy of Enterprise Manager installed on it, and I maintain the SQL databases via the laptop, with no problems whatsoever (over the network inotherwords).
I also have on the laptop a 'frontend' in Access with an ODBC link, so that I can use forms in Access to view the contents of the tables in SQL. I have had no problems with this setup for several weeks (since I created the databases in fact).
However, the problem I have with Access, is that I AM able to alter the information in two of the databases, but NOT the other two. When I try to make changes in either of the two NON working ones, I get a "write conflict - this record has been changed by another user...", however I am THE ONLY user! I am using a SQL Server login, which I have to type in each time I open the Access frontend. What is going on here? I have read something about a timestamp field, but I don't understand why I might have to implement or indeed how to implement? This issue is driving me nuts!
Do the tables you are amending have correct primary keys in the 2 databases which aren't working? The reason I ask is that if Access is unable to determine the exact record you are updating (due to lack of a primary key or other unique field) it will often give the 'Write Conflict' error. As you've mentioned, people often suggest timestamp fields when this issue occurs also, but in my experience this only helps when dealing with Access and MySQL, rather than SQL Server.
Also, which version (and service pack) of Access are you using?
If you have any BIT fields, if you are doing an update on the table, you have to insert a value into the BIT fields, IE "0" into each field. They cannot be null.

SQL Server connection identification

I have several developers which connect to production and test servers where we have DBs with similar names and structures. In SSMS there are info related to the connection, but sometimes are not properly displayed and/or hidden.
I know that it is possible to customize the status bar of each connection in SSMS, but how do you ensure that your developer is connecting to the right server before he runs a query? Is there any way to handle this?
THANKS!
In SSMS, the connection information is displayed on a per query tab basis - all the devs have to do is mind what the tab label says. Click the "New Query" button, and read what the tab is labelled.
After that, it's a matter of knowing which instance is Dev, Test, or Prod. But you can make it more obvious by defining an alias that explicitly says "Dev", "Certification", "Production", etc via the Aliases node in SQL Server Configuration Manager. The caveat is that these are defined on a per workstation basis.
But OrbMan brings up a good point that Production access should be severely limited.
One answer is to not have developers touching production servers, and have deploys managed by someone else. This is often a requirement depending on the sensitivity of the data you are dealing with.
Sounds like your devs require training. Failing that, replace the broken part...

Database Backup

Scenario
i want to take backup from 7 client database to 1 server database.
i dont know structure of the db { either server or client db }.
both databases are having old data. now i have to make the tool take the backup for that.
and should possible to backup old data also[if any updates done on old data.]
please help to find the solution for this.
1. how can i proceed with the problem.
2. database not specified, may be MS access or Sql server 2005
3. In which i can implement this [ I am thinking of doing it in c#]
please help me to find the solution
I'm not sure why you would want to go about it this way - if you are merely trying to copy the client databases (which I interpret as being "file based") then why not simply take copies of their files as part of the wider backup strategy?
If you to write the backup stuff to place all the data in a server based RDBMS, then you are also going to have to think about how you restore that information later on - which presumably means even more coding for you.
So - I don't think this is a good idea, but if you are determined, I would start off by writing a class (which will be almost abstract) dedicated to the purpose of reading the structure of the client database (tables, fields, views etc). I'd then inherit from that to get a specific class for doing this for each individual type of client DB. Once you have that, you can use ADO.Net to read values from the tables in the Client DB, populate datatables with the information, and then write that information back out to the Server based DB.
I really can't stress enough though that I don't like this idea - it seems overly complicated, and also won't deal with functions etc.
Good luck anyway,
Martin
Advisability of doing this aside, one simple answer for a particular subset of the problem would be to create a DSN for a target SQL Server (or any server database) and in Access export table by table to the DSN. You can do this through the Access UI and it can be automated within Access with DoCmd.TransferDatabase. It can be a little fiddly figuring out the proper connect string, and you'd also need to do something about renaming the exported tables so there are no collisions between databases, but that can be handled quite easily in a bit of VBA code.
I post this only because many people overlook the Access capability to export to an ODBC DSN, which requires no writing of DDL and so forth. It may or may not make correct choices about target data types, though, so you'd have to see in any particular situation if it's good enough or not.

How Do I Follow A T-SQL Transaction?

Are there any programs that will allow you to follow a sql transaction through to it's end? For instance, say I've inherited a rather complex sql database with a data dictionary. The data dictionary is pretty good, but not as good as say, SQL Doc. I've taken a look at Red Gate's Dependency Tracker and, while that does a very good job of putting things together (triggers, stored procedures, tables, views, etc.), it still does nothing for following a transaction through it's various tracks.
What I'd like is software that will allow me to enter a transaction and based on everything in my db, tree it out visually to let me see what's happening during the transaction. Does that make sense or do I need to elaborate?
Edited to elaborate: While the answers below were very good, it's not exactly what I'm looking for. The front end of the sql database was built with PowerBuilder. I can use SqlSpy during frontend data input and that helps to follow transactions through, but it's all the t-sql and as you can imagine, reams of output. I'm looking for something that would do the same thing, but lay it out visually with the ability to tree out the detail if I wanted to.
If you open a connection in Visual Studio, you can run sprocs and queries in debug mode. i.e. you can go step by step over a query with intellisense and see the values in the variables.
The SQL Profiler will allow you to trace a transaction through, and see exactly what is going on. It is very flexible and allows you to be shown only the events you are interested in, but it won't show it in the tree format I think you're asking about.
The profiler is installed as part of the SQL Server Client Tools (along with Enterprise Manager and Query Analyser).
I guess if this way is doable. You can set up a test environment and run the transaction. Once transaction is submitted, compare the database in test environment with the prodution database.
You can use some tool to do this comparation. Like OpenDBDiff or you can look for other tool by googling.
I haven't used this yet, it appears to do what you're asking: apply IDE-style debugging tools to T-SQL statements. I woul be interested to see how it works out.

Resources