This question already has an answer here:
Closed 10 years ago.
Possible Duplicate:
Tracing a stored procedure’s parameters handling
Is there any out-of-the-box functionality within SQL Server 2008 that will allow me to see a log of procedures executed, and the parameters passed?
We have a stored procedure whose return is used to determine if a user can log in to our application or not, and the stored procedure is returning some unexpected results. I'm trying to troubleshoot by seeing if the user ID is getting garbled as it's passed to the stored procedure, but I can't quite seem to find where I could go to check that.
Does such a log/viewer exist?
You can use SQL Trace, or SQL profiler, which is essentially a GUI for the same tool.
Details of SQL Trace here msdn.microsoft.com/en-us/library/ms191006(v=sql.105).aspx
Profiler here msdn.microsoft.com/en-us/library/ms181091.aspx
Pete has the right answer if you need to track everything that is run, but if you can modify the procedures yourself you can add logging functionality (something like inserting to a table with the relevant details) directly to the procedure. This avoids the potentially large performance impact of the profiler.
Related
This question already has answers here:
How to auto daily execute queries SQL Server? [duplicate]
(3 answers)
Closed 3 years ago.
I am using SQL Server Management Studio v17.4
I have a view v_fetch_rates. I have created a table using the command
SELECT *
INTO RATES
FROM v_fetch_rates
My question is how do I update the table RATES on daily basis automatically? Is there a way to do it by existing view or do I need to write stored procedure for this?
I did some googling but it confused me even more.
I have never created a job before so any help/resources to refer would help a lot.
If the issue is that the view is slow (because of its definition or the amount of data it returns) and you want to materialized the data in order to improve performance you can simply create a indexed view.
The idea is simple - creating an index on the view forces the engine to materialized it. Of course, there are various limitations and requirements of having index view. You can find more information in the specified link.
If you just want to have the data in a table and populated in on daily basis, you can:
create simple stored procedure which is truncating the current table and populating the data again calling the view
create a complex routine, which will modify (insert/update/delete) data only if needed
I have a stored procedure witch runs several EXEC commands. As a result it returns more than one table. In SQL Server Report Builder or SQL Server Data Tools (SSDT) I can only access the first table it retrieves from this stored procedure. But I need to access last table, in which contains the merged columns from different tables produced by different stored procedures.
I have tried the hide tables other than the last table, but failed. Is there any suggestions you can offer to solve this problem. I appreciate and thank with all my hearth to whom tries to contribute the solution of my problem.
I found a solution for this problem. It is not quite what I have asked but solves this issiue. Here is the solution:
I have edited all sub-stored procedures that I used to "RETURN 0" to prevent them to give an output. So when I call them from Main stored procedure they have no visible output at the "Results" window. Only the Main stored procedure has a single output. Thus I can use it in Report Builder or SSDT like a normal stored procedure without any more modification.
Is Sql server provides us any tool to track the executed procedure with their paramter.. I know this can be done by looking at our server side logic before we call the procedure. But I still want to know if tool exsist or not. If yes then How can do this.
You can use SQL Profiler.
If the stored procedure is called directly from your app, you can use the RPC:starting event. Otherwise you may try to trace the sp:starting event.
For more info check here:
http://sqlity.net/en/976/capturing-parameters-of-a-stored-procedure-call/
So both events do not cover all cases. If you are trying to see all
calls to a procedure from an application, go with RPC:starting. If on
the other hand the procedure gets executed as part of a bigger batch
or from within another procedure, use sp:starting but be aware
that variable usage might hide the actual parameter values from you.
You can setup a custom Data Collector if you have Management Data Warehouse setup on your server. You can also use a DMV to track this, sys.dm_exec_procedure_stats. If you use the dmv, setup a table to store the data, and then dump the dmv data at regular intervals to your table.
This question already has answers here:
How do I find a stored procedure containing <text>?
(21 answers)
Closed 8 years ago.
Whenever I'm developing stored procedures, I often need to do a find/replace or simply just find a keyword (string literal) inside the code. I do this by exporting all of the schema and then doing a find in a text editor, like TextPad.
Where are stored procedures actually stored in the database itself, when you click "Modify" on any stored procedure? That way I can find them and find text in the source code using some keyword without doing an export each time. Is this possible?
Another great tool that would accomplish this is SQL Search, by Red Gate. It's free and easy to use, I use it all the time. It works as an add-in for SSMS.
A few years ago I came across a T-SQL technique to validate a stored procedure in SQL Server, but I cannot find it again
Can probably script the stored procedure calls out with SET NOEXEC ON, so it doesn't actually run anything... This would allow you to catch a lot of basic errors (invalid objects, missing fields, etc.)
Is that along the lines of what you were talking about?
If so, there's a CLR mentioned in SQL Mag that seems to do what you're looking for.