What are the best ways of using the SQL Profiler - sql-server-2008

I am a .NET developer with average SQL skills. I am working on a web app that is 'database heavy'. I have been using the profiler to debug queries and procs. Is there a way to use this tool to look at performance of a query / procedure.
How do I make the most of the SQL Profiler?
I am using SQL Server 2008.

There are no hard and fast rules per say as it depends on the type of database system your a working with.
As a general starting point with SQL Server performance tuning you will find the following reference to be very useful indeed. It contains a variety of considerations and instructions.
http://www.brentozar.com/sql-server-performance-tuning/
Also take a look at the following article, "Identifying Performance issues using SQL Server Profiler"
http://vyaskn.tripod.com/analyzing_profiler_output.htm
If you need additional assistance just drop me a line.

I am not familiar with sql serer 2008, but in sql server 2005 your best bet is the "Display Execution Plan" feature. I will let you know what parts of your query are taking up the most time. Typically adding indexes will help immensely and this tool will help you identify where they are most needed.

Its a wonderful and powerful tool. But be careful and don't do the following"
1) Don't Capture Everything. You can have so many events/objects that you won't be able to find anything. You can set filters by app/user/database.
2) Don't run profiler on the production machine.
3) Don't save the trace info on a production database. Save it to a file that is stored separately from production files.

Related

Link Access to SQL Server 2008 R2 for easier SQL support/editing?

I am trying to develop a proposal for small biz executives to have access to dashboards for up to date financials.
This data can come from various regional/local offices, to be collected and analyzed at the parent/home office.
--Link specific tables in SQL server to Access
QUESTION: I read this is advisable because sometimes it is easier to edit in Access than diretly in SQL Server. It makes support easier. Is this true or is there a better way?
I think that this is a nice way to go. Access offers an excellent RAD environment.
The biggest problem will be when you try to access datasets that are enormous. You will need to be able to write stored procedures in order to summarize the data before it goes over the wire for Access to process. If the datasets are big, you will be using stored procedures or something similar to a pass through query no matter what you use for a front end.

Synchronizing tables on 2 MySQL servers

I have 2 MySQL servers: one for development, other for production. Both contain same table structure, but different data on tables.
When I have done change on dev server, like add column to table, I have manually made the same change later to production server. But this slow and error prone, especially if there are many changes to be made at once.
Is there better way to do this? I have phpMyAdmin, maybe that has some neat trick?
Also, is there a dedicated term for what this process is called? Searching for 'table update' or similar does not yield results on this topic.
EDIT:
Forgot to mention that I am using Windows.
So apparently I need some kind of diff tool for this. I haven't tested all of these proposed software yet, but so far they seem very useful.
I've used Red Gate's SQL Compare before for SQL Server; this is their MySQL product. I don't have the budget to buy it myself, but if it works anything like SQL Compare did, it'll do exactly what you want it to do.
When ever I do this I have used the data or structure sync in a Mysql GUI app called Navicat, there is a free version available and it does what you asked perfectley.
Try to compare and synchronize databases with schema/data comparers in dbForge Studio for MySQL.

Comparing data from two SQL Server databases using build-in tools?

Can I compare the data from two SQL Server 2008 RT databases using built-in tools in SQL Management Studio or do I need to look for some third-party tool to do this?
I've used "the Google" but only seem to get information about third-party tools.
Thanks.
Use Except operator or checksum like i explain in this post.
Just note that the CheckSum method can provide duplicates.
If your database is big, you may want to look into SQL Data Compare.
If you need very sophisticated comparisons you can use Open Source DiffKit:
www.diffkit.org
You can use SQL Server Data Tools. For the most part they work pretty well but they don't have many features and tend to show some limitations on complex tasks.
Third party tools like xSQL Data Compare give you a huge amount of control over the comparison and synchronization process, so I suggest you take a look at those as well.
Dislcaimer: I'm affiliated to xSQL

How to synchronize development and production database

Do you know any applications to synchronize two databases - during development sometimes it's required to add one or two table rows or new table or column.
Usually I write every sql statement in some file and during uploading path I evecute those lines on my production database (earlier backing it up).
I work with mySQL and postreSQL databases.
What is your practise and what applications helps you in that.
You asked for a tool or application answer, but what you really need is a a process answer. The underlying theme here is that you should be versioning your database DDL (and DML, when needed) and providing change scripts to be able to update any version of your database to a higher version.
This set of links provided by Jeff Atwood and written by K. Scott Allen explain in detail what this ought to look like - and they do it better than I can possibly write up here: http://www.codinghorror.com/blog/2008/02/get-your-database-under-version-control.html
For PostgreSQL you could use Another PostgreSQL Diff Tool . It can diff two SQL Dumps very fast (a few seconds on a db with about 300 tables, 50 views and 500 stored procedures). So you can find your changes easily and get a sql diff which you can execute.
From the APGDiff Page:
Another PostgreSQL Diff Tool is simple PostgreSQL diff tool that is useful for schema upgrades. The tool compares two schema dump files and creates output file that is (after some hand-made modifications) suitable for upgrade of old schema.
Have scripts (under source control of course) that you only ever add to the bottom off. That combined with regular restores from your production database to dev you should be golden. If you are strict about it, this works very well.
Otherwise I know lots of people use redgate stuff for SQLServer.
Another vote for RedGate SQL Compare
http://www.red-gate.com/products/SQL_Compare/index.htm
Wouldn't want to live without it!
Edit: Sorry, it seems this is only for SQL Server. Still - if any SQL Server users have the same question I'd definitely recommend this tool.
If you write your SQL statements for your development database (which are, I imagine, series of DDL instructions such as CREATE, ALTER and DROP), why don't you keep track of them by recording them in a table, with a "version" index? You will then be able to:
track your version changes
make a small routine allowing the "automatic" update of your production database by sending the recorded instructions to the database.
I really like the EMS tools.
There tools are available for all popular DB's and you have the same user experience for every type of DB.
One of the tools is the DB Comparer.
TOAD
saved many an ass several times in the past. Why do people run sql with no exit strategy?
the redgate one is good also.
Siebel (CRM, Sales, etc. management product) has a built-in tool to align the production database with the development one (dev2prod).
Otherwise, you've got to stick with manually executed scripts.
Navicat has a structure synchronisation wizard that handles this.
I solve this by using Hibernate. It can detect and autocreate missing tables, columns, etc.
You could add some automation to your current way of doing things by using dbDeploy or a similar script. This will allow you to keep track of your schema changes and to upgrade/rollback your schema as you see fit.
Here's a straight linux bash script I wrote for syncing Magento databases... but you can easily modify it for other uses :)
http://markshust.com/2011/09/08/syncing-magento-instance-production-development
DBV - "Database version control, made easy!" (PHP)

New Project : MySQL or SQL 2005 Express

I am starting a new client/server project at work and I want to start using some of the newer technologies I've been reading about, LINQ and Generics being the main ones. Up until now I have been developing these types of applications with MySQL as clients were unwilling to pay the large licence costs for MSSQL.
I have played around a small amount with the express versions but have never actually developed anything with them. The new application will not have more than 5 concurrent connections but will be needed for daily reporting.
Can MSSQL 2005 express still be downloaded? I cant seem to find it on the microsoft site. I would be hesitant to use MSSQL 2008 on a project so soon after its release.
Are the express version adequate for my needs, I'm sure loads of people reading this have used them. Did you encounter any problems?
The answer to the question on any project in regards to what platform/technologies to use is: What does everyone know best?
Yes express can still be downloaded.
Will it fit your requirements? That depends on your requirements, of course. I have deployed MSSQL2005 Express on several enterprise level projects which I knew had a fixed database size that would never be exceeded (Express has a limit of each database of 4Gb). Also keep in mind there are other hardware constraints such as a 1 cpu limit.
Another thing to consider is if you need the Enterprise level tools that come with a paid edition of SQL Server. If you are moving a lot of flat data around you are stuck writing your own Bulk Copy Procs, which rule the house, but its an extra step, no doubt.
Note sure about #2 but you can download SQL Server Express 2005 here.
Sql express has more features, and is a lot more powerful, but will only run on windows boxes. If you ever need to scale Sql express can be switched easily to a commercial variant.
MySql doesn't support half the features, but does have most of the basic ones you actually need, and will run on windows or *nix boxes. It's also not throttled in the same way as Sql express is.
In my opinion (having used both extensively, but not touched MySql for a few years) Sql express is a far better DB system. If you're building .Net applications the Linq support is a deal clincher.
If you aren't going for pure Sql server support, I wouldn't go for pure MySql support instead. Use a DBFactory design pattern to load your data layer or use simple SQL:92 syntax that's a lowest common denominator.
Why not go to Sql server express 2008?
I'm mostly going to advocate MS SQL Server because of .NET integration. Linq To Sql is pretty much my favorite way to do deal with databases these days: anonymous functions make everything better! My current place of work has also used MSSQL Express for real projects, so you have at least two of us confirming that the restrictions aren't too harsh.
I have about 50 web sites running perl/apache/mysql and about 10 running C#/ASP.Net/SQL Server (Lite) and other (large) applications running on SQL Server (Heavy). I never have problems with SQL Server - it just works. I often have problems with MySQL.
My advice would be to go for the SQL Server based option even if you had to pay for it.