Reviewing text of scheduled job - Transact SQL database - sql

I am using only VS2012 Ultimate Server Xplorer Pane to code and execute my job. I used to add a job scheduling to perform some task at specific time.
Now that I realize my executed command implemented is incorrect. I can delete this by making another new query on the database then recreate a new similar job but I don't want to do this.
I don't know how to fix the command text.

Get Management Studio, and stop trying to do this through Visual Studio.
http://www.microsoft.com/en-us/download/details.aspx?id=43351
Download SQLManagementStudio_x64_ENU.exe (unless you are on x86 for some reason, in which case pick the other one). It's ~1GB, not sure why, sorry about that.
Starting with 2012 SP1, Management Studio Express is fully functional with no license requirement (this is the first time this has happened).
Connect to your server, expand SQL Server Agent > Jobs, and double-click your job. Nice enough UI that will let you edit steps, schedules, etc. without doing any of this hokey generate-an-entire-script-for-a-job stuff...

Related

How to run stored procedure every second automatically (sql server 2014 Express)?

I want to run stored procedure every second automatically.As I am using SQL Server 2014 Express edition so it is not possible to do the same with SQL Server Agent. Also, I don't have any third party tools to do so. I know it can be achieved by using Task Scheduler, sqlcmd utility or by using third-party tools but I don't know the exact way to do that.
I know this can be done and therefore I'm sure it's something I've missed but if anyone can share their experience of this I'd very much appreciate it.
Thanks.
This is a tough one. You're on the right track that you need an outside method to run the job, but I'd recommend writing one yourself to do it if you need the frequency every second (and also question if you really need it every second or not). A service or light application would be the best way to handle it.
I've written an article on setting up Task Scheduler for automated jobs on SQL Server Express, but that has a limit of once/minute. You would use the sqlcmd utility in this case.
You can look at third party utilities like JAMS Scheduler, but their community edition is only free for a year.
That being said, I don't know of any quick-and-easy methods that satisfy your frequency requirements as stated.

Find which line of the SQL is running in SQL Server Management Studio?

I am executing a very long SQL script in SQL Server Management Studio, normally it takes a few second to be done.
But this time it is taking forever and never completes. Other people running this script has no problem.
So I wonder if there is anyway I could debug in SQL Server Management Studio to see which line in this long SQL Script is currently executing and taking forever?
Easiest way is to fire up SQL Server Profiler and trace your SQL with that. As a bonus, you'll get a lot more useful information than simply which line is causing the problem.
If Profiler doesn't give you what you want, have a go with the Activity Monitor. Find your session in the Processes part, and then pull up the details to see the last T-SQ command batch.

Scheduled program VB.NET

I would like to ask for a recommendation for my project.
Basically, it's a scheduled program that shall run at a given period of time, for example,
6:00 pm daily, it includes importing an excel file and inserting it in a sql table.
I have my codes with me, but I dont know how to execute this program automatically.
can you give me some advice
I'm using MSSQL2005 server. And VB.NET language.
Build your application to an executable that just does the task once and use Windows task scheduler.
In my old shop, we occassionally forgot about the one-off tasks running under Task SCheduler, but we had lots of SQL Agent jobs running nightly or weekly. So, just to keep things all together, we created SQL Agent jobs for things like this. So my answer is the same as Bala's, but I would trigger the app through a job on SQL Server instead.
How? Take a look at this: http://bp0.blogger.com/_mDuWqJiJyXE/SB6fy1yBRfI/AAAAAAAAATc/bmdxxAfFTjc/s1600-h/JS_Steps1.png
You could use Visual Studio to create windows service which performs the timed actions...it's a steeper learning curve though.

Is it possible to automate MS SQL Server (2005) queries via SQL Server Management Studio?

I have two queries saved on my SQL Server 2005 and I would like to have them running at certain intervals, e.g. every 24 hours. Is there a way to automate these queries and schedule them via SQL Server Management Studio?
You need to use the SQL Server Agent, installed as part of SQL Server. This is the background service that's responsible for running scheduled maintenance and backup tasks.
Expand the SQL Server Agent node in SQL Server Management Studio, you should see a tree node called "Jobs"
Right-clicking this will give you the option to add a new job. Jobs consist of a series of steps to be executed in order, and when you add a new step to your job, you can choose various types of step, including "Transact-SQL Script"
Create a new job, add a single T-SQL step, put the queries that you want to run into the step properties, and then use the "Schedule" option in the Job properties to create a recurring schedule that'll run the job every 24 hours (or whenever).
You can use the SQL Server Agent, which will allow the server to run the script/stored procedure.
You can also use the Windows Task Scheduler, either on the server or on any other server or workstation to schedule isqlw/sqlcmd to execute your script/stored procedure.
Create a job with a step in which you execute your queries; the job can be scheduled at your needs.
At a previous employer the operations department had a task sheduling application. They prefered to use the command line tools that come with sql server to execute jobs (stored procedures) on a scheduled basis. This way the "task scheduling application" could recieve an exit status (pass/fail, ok/error) and hold up dependent jobs.
I'm sorry I don't remember the name of the command line tool, but it was part of the sql server distro. I also do not remember the name of the task scheduling application. It was not the windows task scheduler. It was something enterprise level used to manage the nightly cycle.
Not sure of the scale of your project, but this is another way to go.
SKapsal's comment on a command line tool for executing SQL commands is a reference to osql (for SQL2000) or sqlcmd (for SQL2005+). You could save your script a file and run it from that command line using Windows Task Scheduler or something similar.
SQL Agent is still the preferred solution, however, as it provides GUI controls for job creation, scheduling, logging and viewing job execution history/results.
how to schedule a job for sql query to run daily?
This is similar question with helpful answer.
Covering simple step by step manual.

How can I monitor the executed sql statements on a SQL Server 2005

In a project of mine the SQL statements that are executed against a SQL Server are failing for some unknown reason. Some of the code is already used in production so debugging it is not an easy task. Therefore I need a way to see in the database itself what SQL statements are used, as the statements are generated at runtime by the project and could be flawed when certain conditions are met.
I therefore considered the possibility to monitor the incoming statements and check myself if I see any flaws.
The database is running on a SQL Server 2005, and I use SQL server management studio express as primary tool to manipulate the database. So my question is, what is the best way to do this?
Seeing how you use the Management Studio Express, I will assume you don't have access to the MSSQL 2005 client tools. If you do, install those, because it includes the SQL profiler which does exactly what you want (and more!). For more info about that one, see msdn.
I found this a while ago, because I was thinking about the exact same thing. I have access to the client tools myself, so I don't really need to yet, but that access is not unlimited (it's through my current job). If you try it out, let me know if it works ;-)
Best way is to fire up profiler, start a trace, save the trace and then rerun the statements