Query to clear sql server logs over a certain age - sql-server-2008

I would like to write a query to clear any SQL Server logs older than 4 days. This is the folder of the SSMS I'm referring to:

Related

SSIS linked to a mySQL server

in SQL server it's possible to link a mySQL server into msSQL and query it using SSMS for example. I want to try this and use SSIS to do some transformations and store all the data on this mySQL database.
\I read that there a several ways to link to mySQL into the msSQL server. OLE DB, mySQL ODBC etc etc.
2 questions:
Are there any limitations i might run into when i will use a combination of SSIS and mySQL instead of msSQL?
When i link a mySQL database into msSQL and i write a query in SSMS, do i write the queries in mySQL language or msSQL language. For example the difference in TOP and LIMIT
I have worked with a linked MySQL Server from SQL Server in the past and ran into some issues.
Querying MySQL from SSMS (SQL Server)
Once you have created a linked server you would imagine you should be able to use the four-part name and query the tables in MySQL but it doesnt allow you. for example you cannot do something like...
Select * from MySqlServer.DbName.Schema.TableName
For some reason it throws an error. So the question whether I can use T-SQL in SSMS to query a Linked MySQL Server? Nope, unfortunately not.
But alternatively Microsoft recommends using OPENQUERY to execute queries to a linked server.
When using OPENQUERY, SQL Server does not try to parse the query, it just sends it to the linked server as it is. which means you can/should be able to write MySQL in SSMS using OPENQUERY and it will work.
Using SSIS with MySQL
Even though SSIS is Microsoft's tool that comes with SQL Server but it is a proper ETL tool which can read data from multiple sources and send data to many types of destination.
Once you have used the appropriate driver to connect to MySQL and ported data in SSIS package , its really not relevant anymore, where the data came from? you would have access to all the SSIS tools and you should be able to use them as if the data was coming from a flat file, SQL Server or Excel sheet etc.
By using Linked Server in MSSQL you can also connect to mySql. for that you need to download ODBC drivers. and then you have to create new dsn and while creating dsn you have to insert mySql server's details. then you can further search regarding how to create Linked server on SQL SERVER. This option is very easy and Totally free. You can use OPEN QUERY FOR inserting, updating, deleting and also get the data out from mySQL.

Updating MySQL with data from MS SQL Server

In MySQL is it possible to execute an update query with values selected from external MS SQL database?
I would like to execute every night a timed query, which updates some the data in MySQL with data on MS SQL server.
Typically how you would do this is, create a SSIS package (dts) that pulls the data in and does anything else you want to do. Then setup a SQL job to run the package, then Setup a A SQL batch to kick off the job whenever you want it to run

SQL Remote query very slow after migrating sql server

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.

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.