SQL Remote query very slow after migrating sql server - sql-server-2008

I have a Sql Server 2005 express edition with one Database. I have too a C# winforms application to access to table customers that has 500 rows aprox. I have the sql server 2005 Express inside the local pc with the winforms app.
Now I've bought a server with SQL Server 2008 standard edition and I've migrated my database to that server and reconfigured my application to access to the new server throught Lan.
The problem is that a simple query like SELECT name, lastname,phone,fax,address FROM Customer ORDER BY name (I have 500 rows) If I execute it in the server, it runs in 1 second but if I open my application (in other pc trought lan, not in the server) it takes about 4 minutes to return the results.
I don't know what to do because the database is very very small.
Thanks

One thing to try is to run a SQL Profiler and see from the trace if the query itself is actually taking 4 seconds to execute when coming from your client.
some info on how to create a trace using the profiler here:
http://sqlserverpedia.com/wiki/Using_SQL_Server_Profiler
and here
http://databases.about.com/od/sqlserver/ht/trace.htm or http://www.mssqltips.com/sqlservertip/2232/working-with-sql-server-profiler-trace-files/
I would guess that the query itself is probably running in the same amount of time no matter where the query is issued and the trace can help prove this. Run the query locally, then remotely and compare the duration for each of these requests. if the times are close you can be confident that the actual query is not at fault and you can concentrate on identifying other sources of latency - perhaps network, etc.

Related

Transfer sql server data to mysql database using program

I have an old system with sql server database. And I have to create a webiste with mysql database. The old system is still in use and is inserting data to the sql server DB everyday. So, I am thinking write a program that automatically transfer data from the sql server DB to the mysql DB. Any good suggestions? Thanks.
You have an active SQL Server database.
Unless you are planning to decommission this database server (for very good reasons not related to this new application), then the new application should simply query this server.
You can create a small (Maybe in c#) program that keeps running all the times with a timer, and on this timer, get all rows from SQL server that are not marked as "Copied", insert them on MySQL and the update those rows as "Copied". That program need to have access to both databases.

SQL Server 2008 - moving data from SQL Server 2000

Our company is getting ready to move next week and we currently use SQL Server 2000 for all our databases, hosted in our own building. They've decided to move the data to a local company for several reasons, but they are running SQL Server 2008.
I'd like advice on a few things:
We are trying to setup a test for just a few of our databases to see what breaks with our apps (connection strings, etc.). What is the best way to get a database from our SQL Server 2000 box to the new box without losing data or having to recreate the table, etc. I tried the DB Copy Wizard but restrictions within our network don't allow it. If I create a DB on SQL Server 2008 and perform a RESTORE from the SQL Server 2000 .bak file, I will lose all the transactions, correct? What if I replace the transaction files later? I'm thinking that won't work though.
How to properly upgrade a SQL Server 2000 database to SQL Server 2008? I've run the wizard against most of our databases and it came up clean with the exception of a few minor issues that I can resolve.
Our SQL Server 2000 is our production server so it can't go down at any point to copy files.... not until the move. Our customers have been notified that there will be a short outage period between certain dates so that's ok, but I guess what I'm saying is I can't stop the SQL Server Agent right now just to copy log files and such for testing purposes.
Any help/advice is greatly appreciated!
Create a database backup of the SQL Server 2000 and restore it to the SQL Server 2008.
Setup replication making the SQL Server 2000 as the Publisher and the SQL Server 2008 as the Subscriber.
Not sure which would be the best approach. I think a DB backup and restore would be a good idea. You will loose some data in the mean time, though.
If you were migrating between 2 versions of 2005 or 2008 I would advise a log backup to reduce the data lost but I don't think that this option is available on 2000
One piece of advice I can give you is to take a look at the discontinued features from 2000 and 2005 and from 2005 and 2008 on these links:
2005
2008
Just back up 2000, and then restore it. You won't lose transactions, no difefrent to doing a full backup on your current server.
You'll need to add any SQl logins and set the permissions etc.
You'll need to to do fix users for them as well.
If you only use integrated access then you don't need to.
e.g.
Use MyDataBase
EXEC sp_change_users_login Auto_Fix, 'MyUser'
And you'll need to set the compatibility level
Use
exec sp_bcp_dbcmptlevel 'model'
to get it
and then
EXEC sp_dbcmptlevel 'MyDatabase', ??
to set it.
Another option, would be to install 2000 on your new machine restore a back from the old one and then do an inplace upgrade through the 2008 installation wizard. That sort of thing tends to give my sphincters palpitations though.

Slow Queries when using MySQL as a Linked Server from SQL Server (ODBC Connection)

I'm seeing very poor query performance when running a stored routine on a MySQL linked server from a SQL Server. The query runs from the SQL Server
select * from OPENQUERY(COGNOS, 'call reporting.sr_vendor_location_report(''2011-06-13 00:00:00'',''2012-01-18 00:00:00'',1,''0,1'',28,''(All)'',''(All)'',1,''(All)'')')
takes 15 seconds but if I check the mysql query log or run it on the server directly, I see that it only takes 7 seconds.
I've read elsewhere that MySQL ODBC connections are slow but I haven't seen any solutions suggested. I tried setting up mysql-proxy (just running it with a redirection - no LUA scripts) but didn't see any improvement. I'm using the MySQL ODBC Connector 5.1 and running MySQL version 5.5 on the server.
I'd be enormously grateful for any ideas on what to try.
UPDATE
It turns out that openquery runs each query twice on the mysql server, the first time presumably to get metadata. Is there any way to avoid this?
try to configure the provider to run out-of-process (right click on the provider and uncheck the allow in process box).
This is not exactly a setting related with performance, but I saw good performance gains in some cases with oracle, maybe it works with mysql too.
It turns out that using RPC instead of OPENQUERY solves the problem of SQL Server generating two queries.
e.g.
select * from OPENQUERY(COGNOS, 'call reporting.sr_vendor_location_report(''2011-06-13 00:00:00'',''2012-01-18 00:00:00'',1,''0,1'',28,''(All)'',''(All)'',1,''(All)'')')
becomes
exec('call ...') at COGNOS

SQL Server not running queries on remote (Linked MySQL) server

For various horrible reasons, we've had to link SQL Server to a MySQL database using Linked Servers and an ODBC Data Source. The queries run fine, but looking at the query plans you can see that SQL Server is always doing a full table scan on the remote server - and then doing any joins/filtering at the SQL Server end.
How can we push these to the MySQL server instead?
Thanks
James
If you write your queries like this ...
select * from openquery
( myLinkedServer
,'Select * from mySQLTables where complicated joins/filters')
the joins/filters should happen remotely.

MySql emulation running on Microsoft SQL 2008

We have an application that cannot be altered. The only configuration changes permitted on the application are : host ip, username and password.
The application streams data into a MySql database. Another application then sends this data onto a Microsoft SQL 2008 server.
I would like to remove this middle step and wondered if anyone knew of a way that Microsoft SQL Server 2008 could be configured to 'pretend' to be a MySql database?
Your help is very much appreciated.
Why 'send' the data to the SQL Server when you can just create a linked server?
It cannot be done. MySql and MSSQL are 2 completely different products with different connectionprotocols, a different SQL dialect, different behaviour at times and so on.
I'm sorry.