Schedule/Edit Maintenance Tasks for SQL Express (No Maintenance Plan Wizard) - sql

I am using SQL Server 11.0.6251 Express (SQL Server 2012 Express). I have some software that logs data to the database continuously. However, there are some maintenance tasks that are performed on the database every so often. Whenever this happens, there are some data points that don't get logged.
I want to reschedule and configure these maintenance tasks so that I can recreate the problem and troubleshoot the software so that I don't lose any more data points.
I am aware that an easy way to do this is to just upgrade SQL Server so that I have the maintenance plan wizard and SQL Server agent. I just want to see if any of you SQL gurus out there know a way around this problem!
I've also looked into how scripts and using the Windows Task Scheduler can help create maintenance plans, but I'm not sure how to use that to edit existing maintenance tasks.
Is there any way to edit and re-schedule current Maintenance Tasks for SQL Server Express?

Related

SQL Server 2016 point in time replication tool

I need to run an end of day 'replication tool/application' on a SQL Server 2016 Always-On DB (1 Primary, 2 Sync, 1 Async). The job needs to run at a point in time when the DB is serving limited web traffic but I can't stop the Web/Application layer being up 24/7.
e.g., my requirement is to replicate all data in the DB at 1am.
I was wondering how best to solve this:
Create a Backup and Restore of the Async DB and then run the replication tool off this "new DB".
Create a DB snapshot of the Async DB and then run the replication tool of the snapshot
Something much easier I'm missing
*Note the tool I'm using proprietary to a product and I can't use any native SQL replication tools.
Many thanks

MSSQL Automated Jobs

I have been recently reading about configuring jobs within SQL Server and that they can be configured to do specific tasks.
I recently had issues whereby all the DB indexes where > 75% fragmented and I wondered if there was a way to have SQL Server automatically manage itself.
Now when reading about setting up and configuring jobs it mentions the SQL Server Agent.
In the DB Server I was looking at the SQL Server Agent was switched off.
This made me think that having a "job" to handle the rebuilding/reorganising of indexes may not be great if this agent can simply be disabled...
Is there anything at a DB level which can be configured to do this, or is this still really in the hands of a "DBA"?
So to summarise, my question is, what is the best way to handle rebuilding/reorganising indexes?
A job calling some stored procedures could be your answer.
Automation of this task depends on your DB: volume of data, fragmentation degree, batch updates, etc.
I recommend you to check regularly your index fragmentation, before applying an automatized solution.
Also, you can programmatically check if SQL Server Agent is running.

SQL Server: Database Maintenance Plan

I have a small database for a school project and I need to create a Database Maintenance Plan with the following requirements:
it has to manually (through scripting and not user interface)
it must reorganize data and indexes
it must validate database integrity
it must be run automatically everyday at 19:00
well, I have absolutely no idea on how to do this
Can someone help me out, please?
I found some commands to create backups and reorganize indexes but I can't find a way to run them periodically.
Thanks
Chiapa
If you want to create a maintenance plan, see the follwing page:
Use the Maintenance Plan Wizard
Otherwise, you can just create a SQL agent job with various steps in it that run the T-SQL commands that you want, such as backup database and DBCC commands and create a schedule for it.
If you cannot use the maintenance plan wizard, you can use commands similar to those detailed in the following page to create the jobs:
Create a Maintenance Plan
If you can't create agent jobs (for reasons such as you are using a version of SQL server that doesn't support them (SQL Express etc) then you can use OSQL commands that are fired by Windows task scheduler to achieve much the same thing, see the folowing link for a very good description:
How to Automate Maintenace Tasks with SQL Server Express
If you have the commands available and you're on an edition of SQL Server that has a SQL Agent, create an agent job and use that to do the scheduling.

Best way to sync SQL 2000 and 2005 databases

I have a production database in SQL 2000 and a SQL 2005 instance will be installed in a new server. I would like to have an updated copy of one SQL 2000 database in my SQL 2005 at anytime.
What is the best way to implement database sync between this two SQL versions?
You can create an SSIS package to do this and schedule it as a job.
Or if this is development machine that you want to keep you can do all the development on the 2005 database in scripts kept in source control (which is of course what you should be doing), then you take the most recent backup, restore it to the database and run any change scripts you need.
Or use Red_gate's SQL data compare. It costs money but its worth it.
if "anytime" means you need the data to be updated as soon as it changes, i would think about triggering the tables on the 2000 server to mirror the operation on the 2005 server.
or, a DTS on the 2000 server might do the job, but i have no experience with those (they are also deprecated if i'm not mistaken).
or, some scheduled jobs might keep data in sync between the servers (but they'll be out of sync until the next job run)
hope this helps, myself i'd go with triggering since it's a "set and forget" approach.

Windows Service or SQL Job?

I have an archiving process that basically deletes archived records after a set number of days. Is it better to write a scheduled SQL job or a windows service to accomplish the deletion? The database is mssql2005.
Update:
To speak to some of the answers below, this question is regarding an in house application and not a distributed product.
It depends on what you want to accomplish.
Do you want to store the deleted archives somewhere? Log the changes? An SQL Job should perform better since it is run directly in the database, but it is easier to give a service acces to resources outside the database. So it depends on what you want to do,,,
I would think a scheduled SQL job would be a safer solution since if the database is migrated to a new machine, someone doing the migration might forget that there is a windows service involved and forget to start/install it on the new server.
In the past we've had a number of SQL Jobs run. Recently, however, we've been moving to calling those processes from .Net code as a client application run from a windows schedule task, for two reasons:
It's easier to implement features like logging this way.
We have other batch jobs that don't run in the database, and therefore must be in windows scheduled tasks. This way all the batch jobs of any type will be listed in one place.
Please note that regardless of how you do it, for this task you do not want a service. Services run all day, and will consume a bit of the server's ram all day.
In this, you have a task you need to run, and run once a day, every day. As such, you'd either want a job in SQL Server or as Joel described an application (console or winforms) that was setup on a schedule to execute and then unload from the server's memory space.
Is this for you/in house, or is this part of a product that you distribute.
If in house, I'd say the SQL job. That's just another service too.
If it's part of a product that you distribute, I would consider how the installation and support will be.
To follow on Corey's point, if this is externally distributed, will you need to support SQL Express? If not, I'd go with the SQL job directly. Otherwise, you'll have to get more creative as SQL Express does not have the SQL Agent that comes with the full versions of SQL 2005 (as well as MSDE). Without the SQL Agent, you'll need another way to automatically fire the job. It could be a windows service, a scheduled task (calling a .NET app, powershell script, VBscript, etc.), or you could try to implement some trigger in SQL Server directly.