How to run stored procedure every second automatically (sql server 2014 Express)? - sql-server-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.

Related

How can I see which tables are changed in SQL Server?

I have a database which I didn't make and now I have to work on that database. I have to insert some information, but some information must be saved in not one table but several tables. I
can use the program which have made the database and insert information with that. While I am doing that, I want to see that which tables are updated. I heard that SQL Server Management Studio has a tool or something which make us see changes.
Do you know something like that? If you don't, how can I see changes on the database's tables? If you don't understand my question, please ask what I mean. Thanks
Edit : Yes absolutely Sql Profiler is what I want but I am using SQL Server 2008 R2 Express and in Express edition, Sql Profiler tool does not exist in Tools menu option. Now I am looking for how to add it.
Edit 2 : Thank you all especially #SchmitzIT for his pictured answer. I upgraded my SQL Server Management Studio from 2008 R2 express edition to 2012 Web Developer Edition. SQL Profiller Trace definitely works.
I agree with #Lmu92. SQL Server Profiler is what you want.
From SQL Server Management Studio, click on the "Tools" menu option, and then select to use "SQL SErver Profiler" to launch the tool. The profier will allow you to see statements executed against the database in real time, along with statistics on these statements (time spent handling the request, as well as stats on the impact of a statement on the server itself).
The statistics can be a real help when you're troubleshooting performance, as it can help you identify long running queries, or queries that have a significant impact on your disk system.
On a busy database, you might end up seeing a lot of information zip by, so the key to figuring out what's happening behind the scenes is to ensure that you implement proper filtering on the events.
To do so, after you connect Profiler to your server, in the "Trace properties" screen, click the "Events Selection" tab:
You probably are good to uncheck the boxes in front of the "Audit" columns, as they are not relevant for your specific issue. However, the important bit on this screen is the "Column filters" button:
This is where you will be able to implement filters that only show you the data you want to see. You can, for instance, add a filter to the "ApplicationName", to ensure you only see events generated by an application with the name you specify. Simply click on the "+" sign next to "Like", and you will be able to fill in an application name in the textbox.
You can choose to add additional filters if you want (like "NTUsername" to filter by AD username, or "LoginName" for an SQL Server user.
Once you are satisfied with the results, click "OK", and you will hopefully start seeing some results. Then you can simply use the app to perform the task you want while the profiler trace runs, and stop it once you are done.
You can then scroll through the collected data to see what exactly it has been doing to your database. Results can also be stored as a table for easy querying.
Hope this helps.
Although you describe in your question what you want, you don't explain why you want it. This would be helpful to properly answer your question.
ExpressProfiler is a free profiler that might meet your needs.
If you're looking to track DDL changes to your database, rather than all queries made against it, you might find SQL Lighthouse useful, once it is released in Beta shortly.
Disclosure: I work for Red Gate.
Do you know something like that? If you don't, how can I see changes
on the database's tables? If you don't understand my question, please
ask what I mean. Thanks
Red gate makes a lot of great tools. You can always make a database comparison. That will require that you make a backup, then doing whatever you want to do, and the compare the two databases, there is a free trial, works perfect to compare which tables has changed (deleted/inserted and modified)
http://www.red-gate.com/products/sql-development/sql-data-compare/
what you might maybe be looking for is "SQL Server Profiler". It's a SQL monitor where you can see all the SQL queries running real time.
http://technet.microsoft.com/en-us/library/aa173918(v=sql.80).aspx
Hope that helps you.
As far as I know SQL Profiler tool is not included in the Express edition of SQL Server (only Developer edition contains it). Maybe you can purchase it separately.
If you want you can try this https://sites.google.com/site/sqlprofiler/ free tool for profiling. Maybe it has limitations, but it you can check it.
There are also some profiling tools for integration with Visual studio, and also the ReSharper has InteliTrace (if you are using the tool at all).
Cheers.

Is there a log in SQL Server where I can read what commands have been executed?

I'm using SQL Server 2008 and need to see a list of what commands have been exectued and when. Is this possible? How can I read such log?
Duplicated question (I guess)
Looking for a SQL Transaction Log file viewer
You can use third party software to read transaction logs.
http://www.red-gate.com/products/dba/sql-log-rescue/
http://www.apexsql.com/sql_tools_log.aspx
http://www.toadworld.com/products/toad-for-sql-server/w/wiki/10586.log-reader.aspx
And if you want to audit truncate command try to audit all commands executed on your database.
http://www.databasejournal.com/features/mssql/article.php/3861791/Database-Level-Auditing-with-Microsoft-SQL-Server-2008.htm
There are some commercial products which will do this like Apex SQL Log and I think Red Gate might do one too, which give you a nice GUI to do all this but it is possible to do all this without them. That being said, if you only need to do this once then you might get away with juts downloading and using a trial version of one of these products.
This tutorial shows you how to get started extracting information from the log using T-SQL and an undocumented function called fn_dblog. However, the caveat here, as always with undocumented features, is that you should not rely on it in production code in case it disappears without warning, which it may. If you're just using it to investigate something and not using it on a scheduled basis or anything then you'll be fine.
There are quite a few other tutorials out there that use fn_dblog as well, so just have a look on your favourite search engine. It is worth readin up on this function before using it as the information it returns isn't all that straightforward.

New to SQL servers, wanting to schedule table / data moves every X hours

I have looked at a few stackoverflow forum posts but nothing fits (or atleast I dont think so) what I need help with.
I'm looking for general advise, my company has 'tasked' me to look at moving some data from tables stored in our parent companies databases into a database of our own that has all the information we need in one place.
For instance if we want information that related to one thing, we may have to pull data from several different databases. I think I can get my head around the moving of the data and create a sql query to do it, however we're currently using SQL express as our SQL db (the company is more than happy to buy/create a SQL server but as far as we can see SQL express does what we need it too (feel free to correct me)).
I need to look at scheduling the data move for every hour or few hours to keep the data 'up to date' for when reports are generated using the data.
I have looked at a few programs but the as the queries and the database is on a server 2008 r2 system some of the 'programs' don't like it as they were last updated pre 2010 etc. I have also installed SQL management suite 2012 due to SQL server agent but I cant even get that worked (Service is enabled and I have restarted the DB just still nothing within suite).
I'm not looking (however happy to take the help) for a 'Do this and that and that' type reply but more than happy to accept that amount of help but if you guys / gals can point me in the right direction.
Summary:
-Combining data already on databases from our parent company into a table / DB of our own making
-Currently using SQL Express but willing to upgrade to something else that does the job
-Schedule the data moves for every X hours (Windows scheduling?)
-automating the entire thing so don't have to manually do the moves.
Help on any of the points above would be greatly appreciated and I would 'love you long time' for the help.
JB
There are a bunch of limitations for SQL Express. One of them is that SQL Agent is not supported. SSIS like SQL Agent is not supported.
http://msdn.microsoft.com/en-us/library/cc645993.aspx
Do not fret, you can always schedule a job with Windows Scheduler.
http://windows.microsoft.com/en-US/windows/schedule-task#1TC=windows-7
As for moving the data, it is up to you to select a solution.
1 - Write a PowerShell application to perform the Extract, Translate, and Load (ETL).
http://technet.microsoft.com/en-us/library/cc281945(v=sql.105).aspx
2 - Use the SQLCMD to perform logic like calling stored procedures.
http://technet.microsoft.com/en-us/library/ms162773.aspx
3 - Use BCP to dump and load data.
http://craftydba.com/?p=1245
http://craftydba.com/?p=1255
http://craftydba.com/?p=1584
http://craftydba.com/?p=1690
It is funny how youngsters think they need to spend a-lot of $ to create a solution for a business.
However, Microsoft does supply you with a-lot of free tools.
You just have to put them together for a solution.
PS: I remember about 10 years ago I created a custom ETL solution using VBSCRIPT. Unlike power shell, it is installed on old and new programs.
Good luck!
You can create a console application which executes that particular stored procedure which handles your logic. ( http://dotnet.dzone.com/articles/basics-stored-procedures-net )
Of course using SSIS is much easier but it's not available in SQL Server Express Edition.
I think you should have a look at Integartion Services, which is not available for Express Edition. Have a look at this article to get started with SSIS.

SQL Server activity monitor show all queries

I'm using SQL Server 2005, and I'd like to know if there is any possibility to watch every query sent to SQL server?
SQL Server Management Studio has a built-in tool called the Activity Monitor which gives me nearly what I am searching for in the "Recent Expensive Queries Pane"
This pane shows information about the most expensive queries that have been run on the instance over the last 30 seconds.
I need exactly this for all recent queries, not just the expensive ones...
Can anyone help me?
Name a tool, or give me a hint what to search for...
To watch every query sent to SQL server using SQL profiler, you can use one of SQL Profiler predefined templates. It's TSQL_Duration.
It's designed to track completed stored procedures and TSQL code.
The trace will show you exactly the batch executed.
You can expand the events tracked and columns shown.You can find more information here: How To: Use SQL Profiler
The same feature is also available in ApexSQL Comply, an auditing tool that uses SQL traces to capture the events, then stores them in a central repository database, and provides built-in and custom reports where you can easily filter the transactions, and export them as Excel, Word, or PDF files.
Disclaimer: I work for ApexSQL as a Support Engineer
You're looking for SQL Profiler, it's usually installed along with SSMS.

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