Audit stored procedure execution details in sql server
Hi All,
how to find stored procedue details and which parameters passed in stored proceduer and out put details in sql server.
how can we audit stored procedure details.
/Raghavendra
http://technet.microsoft.com/en-us/library/ms189751.aspx
In SQL Server, requires ALTER ANY LOGIN permission on the server or membership in the securityadmin fixed server role.
In SQL Database, only the server-level principal login (created by the provisioning process) or members of the loginmanager database role in the master database can create
new logins.
If the CREDENTIAL option is used, also requires ALTER ANY CREDENTIAL permission on the server.
Best Regards,Uri Dimant SQL Server MVP,
http://sqlblog.com/blogs/uri_dimant/
MS SQL optimization: MS SQL Development and Optimization
MS SQL Consulting:
Large scale of database and data cleansing
Remote DBA Services:
Improves MS SQL Database Performance
SQL Server Integration Services:
Business Intelligence
Similar Messages
-
How can I get a list of values (one or more) used in the WHERE filter of stored procedures and functions in SQL Server?
How can get a list of values as shown (highlighted) in the sample stored procedure below?
ALTER PROC [dbo].[sp_LoanInfo_Data_Extract] AS
SELECT [LOAN_ACCT].PROD_DT,
[LOAN_ACCT].ACCT_NBR,
[LOAN_NOTE2].OFCR_CD,
[LOAN_NOTE1].CURR_PRIN_BAL_AMT,
[LOAN_NOTE2].BR_NBR,
INTO #Table1
FROM
dbo.[LOAN_NOTE1],
dbo.[LOAN_NOTE2],
dbo.[LOAN_ACCT]
WHERE
[LOAN_ACCT].PROD_DT = [LOAN_NOTE1].PROD_DT
and
[LOAN_ACCT].ACCT_NBR = [LOAN_NOTE1].ACCT_NBR
and
[LOAN_NOTE1].PROD_DT = [LOAN_NOTE2].PROD_DT
and
[LOAN_NOTE1].MSTR_ACCT_NBR = [LOAN_NOTE2].MSTR_ACCT_NBR
and
[LOAN_ACCT].PROD_DT = '2015-03-10'
and
[LOAN_ACCT].ACCT_STAT_CD IN
('A','D')
and
[LOAN_NOTE2].LOAN_STAT_CD IN
('J','Z')
LenfinkelHi LenFinkel,
May I know what is purpose of this requirement, as olaf said,you may parse the T-SQL code (or the execution plan), which is not that easy.
I have noticed that the condition values in your Stored Procedure(SP) are hard coded and among them there is a date values, I believe some day you may have to alter the SP when the date expires. So why not declare 3 parameters of the SP instead hard coding?
For multiple values paramter you can use a
table-valued parameter. Then there's no problem getting the values.
If you could elaborate your purpose, we may help to find better workaround.
Eric Zhang
TechNet Community Support -
Hi,
How do I return two values from a
stored procedure into an "Execute SQL Task" please? Each of these two values need to be populated into an SSIS variable for later processing, e.g. StartDate and EndDate.
Thinking about stored procedure output parameters for example. Is there anything special I need to bear in mind to ensure that the SSIS variables are populated with the updated stored procedure output parameter values?
Something like ?
CREATE PROCEDURE [etl].[ConvertPeriodToStartAndEndDate]
@intPeriod INT,
@strPeriod_Length NVARCHAR(1),
@dtStart NVARCHAR(8) OUTPUT,
@dtEnd NVARCHAR(8) OUTPUT
AS
then within the SSIS component; -
Kind Regards,
Kieran.
Kieran Patrick Wood http://www.innovativebusinessintelligence.com http://uk.linkedin.com/in/kieranpatrickwood http://kieranwood.wordpress.com/Below execute statement should work along the parameter mapping which you have provided. Also try specifying the parameter size property as default.
Exec [etl].[ConvertPeriodToStartAndEndDate] ?,?,? output, ? output
Add a script task to check ssis variables values using,
Msgbox(Dts.Variables("User::strExtractStartDate").Value)
Do not forget to add the property "readOnlyVariables" as strExtractStartDate variable to check for only one variable.
Regards, RSingh -
How to call procedure in Java from SQL Server Database
Hello Every Body
i Have Question about
How to call procedure in Java from SQL Server Database
ThanksHi,
have you tried a Google search? I just gave it a 3 second try and already found: http://stackoverflow.com/questions/6113674/how-do-i-execute-a-ms-sql-server-stored-procedure-in-java-jsp-returning-table-d
Frank -
Calling stored procedure from script on remote server
We are migrating our database to a virtual server environment. On the current dedicated environment, the database and scripts(calling stored procedures) are on the same server. In the new envoirnment, the scripts, input and output files will be on a different server. Does anyone have any examples of scripts on one server calling stored procedures on another server. Don't laugh, but the db server is currently running Oracle 9i (part of the new enviornment to move to 11g).
brifry wrote:
sorry my terminolgy is not correct. the stored procedure is in the database and the database is on server a. The script is on server b. In your example you show how to log onto the database. That I know. In your example your example, how would you point to server b so you can log onto the database?Do you want to mean that your procedure (location A) want to call a script from location B ?
make the script located folder as shared and ,You may try this
//server_name/folder_name/file_name.xxxHope this helps -
Pricing Details for SQL Server
Hi,
I have tried to find pricing detail for SQL Server and found below link. Not sure whether below link include pricing of SSIS , SSAS or SSRS i think so it includes that...?. How much I can pay if I have to use SSIS and SSRS its same per minute or if i have to
use SSIS, SSAS and SSRS its same price per minute ? Please provide details i have to finalize few things...
http://azure.microsoft.com/en-us/pricing/details/virtual-machines/#sql-server
Thanks in Advance
Haseeb KhanHello,
Since the question is a license issue, you can call 1-800-426-9400, Monday through Friday, 6:00 A.M. to 6:00 P.M. (Pacific
Time) to speak directly to a Microsoft licensing specialist. You can also visit the following site for more information and support on licensing issues:
http://www.microsoft.com/licensing/mla/default.aspx
Hope this helps.
Regards,
Alberto Morillo
SQLCoffee.com -
How to wrap a stored procedure that outputs PL/SQL records for JDBC?
Hello everybody,
Is there an example for wrapping a stored procedure that outputs PL/SQL records and/or PL/SQL tables of records, so that it can be called from JDBC?
Since this is not possible with the Oracle JDBC driver, Oracle recommends "To wrap a stored procedure that uses PL/SQL tables, break the data into components or perhaps use Oracle collection types." (http://download-west.oracle.com/docs/cd/B12037_01/java.101/b10979/ref.htm#sthref2123)
Many thanks for any help,
Cheers, ChristophHi Christoph,
Have you tried using JPublisher, or -more easily- JDeveloper (Go to your database connection in the "Connections" pane, open the "Packages" node, right click to "Generate Java...").
These approaches (at minimum, use of jpub) will generate required PL/SQL wrapper code, including SQL Type declarations. Once these are installed in the database, you can invoke the wrapper procedures directly from Java.
-- Ekkehard -
how to use ADO(Microsoft ActiveX Data Objective 2.8 Library) to execute the store procedure of database in SQL server?
Does any body can tell me about this?
thanks
[email protected]Hi
Did you succeed to execute the procedure?
How ?
Thanks
Shimon Zerbib -
SQL stored procedure execution takes 5x as long using PS 3.0
I have a stored procedure that populates some reporting table, does not return any results, and is very expensive. However it completes in 5 minutes when executed using SSMS. When the same stored procedure is executed though PS 3.0 it runs in
almost 25 minutes. The condensed code is shown below. The $Connection is defined elsewhere and is already open at this point.
$Command = New-Object Data.OleDb.OleDbCommand
$Command.CommandTimeout = 600
$Command.CommandText = "dbo.usp_extract_exact_target_user @in_all_flg = 1"
$Command.Connection = $Connection
$Command.ExecuteNonQuery()
Can anyone tell me where I'm going wrong, or what could be causing the 5x execution times?
Thanks in advance for help; you can offer.Not Powershell. Powershell does nothing but hand the command to the database server.
Why are you using OldDB? You should be using the SQLClient.
system.data.sqlclient.sqlconnection
system.data.sqlclient.sqlcommand
Everything else should be the same.
You should also prep and bind your arguments.
¯\_(ツ)_/¯ -
Convert Informix "with resume" feature in stored procedures to Oracle PL/SQL
I am trying to convert an Informix stored procedure with the "return value with resume"
feature into Oracle PL/SQL.
So far, all I have gathered is that I need to use packages and reference cursors.
What is hazy is that how and when does this value get returned? Is it on the execution of the FETCH statement or do I need to specify a RETURN statement.
If anybody has any ideas or better yet any
concrete examples, please email me.
Thank you.This is a small example of the use of ref cursor , for further details see the Oracle documentation
PL/SQL User's Guide and Reference
Release 8.1.6
A77069-01 . The stored procedure converter for informix (downloadable from Oracle Technology Network) does not unfortunately cover this situation.
Turloch
create or replace PACKAGE BYROYALTYPkg AS
TYPE RT1 IS RECORD (
val MTG_VERSION.VERSION%TYPE
TYPE RCT1 IS REF CURSOR RETURN RT1;
PROCEDURE byroyalty(
RC1 IN OUT BYROYALTYPkg.RCT1);
END;
create or replace PACKAGE BODY BYROYALTYPkg AS
PROCEDURE byroyalty(
RC1 IN OUT BYROYALTYPkg.RCT1)
AS
BEGIN
OPEN RC1 FOR
SELECT VERSION FROM MTG_VERSION;
END byroyalty;
END; -
Calling Stored Procedure with TestStand to SQL 2000
When I run the Stored Procedure in the query analyzer it returns the recordset fine. I am not specifying any parameters. I am Using TestStand 2.01 and SQL Server 2000. I am using the OPEN SQL STATEMENT step to call the SP. When I run the SP in TestStand I get no data returned. If I run the SQL statment in TestStand I get the data that I am requesting. Does TestStand not support stored procedures.
Hi,
The instructions that I posted were for TestStand 3.0. In version 3.0 you can call stored procedures with input/output paramateres and to support this functionality the data operation step support several new modes.
TestStand 2.0.1 does not support parameters on stored procedures, but it does support calling stored procedures that do not take parameters. To be able to access the data back from the database you need to set the cursor location (in the Advanced tab of the Open SQL Statement step) to Client (http://digital.ni.com/public.nsf/websearch/0EF68BF97AB1A61F86256B8E007D70C0?OpenDocument).
By changing the cursor to Client I was able to succesfully call a stored procedure from TestStand 2.0.1 and to read back the recordse
t return by the database. Please let me know if you are still experiencing dificulties.
Best regards,
Alejandro del Castillo
National Instruments -
Please help convert MSSQL Stored Procedure to Oracle PL/SQL
Hi there to all,
this be my first post to these forums. I have already posted this question on a microsoft msdn forum, until someone advised that I ask my question here - dunno why I didnt think of that! ?:|
Im working with an Oracle 10g Database from an ASP.NET 2.0 application, and want to know if it Oracle supports OPENXML (rhetorical question I fear!). The reason I ask is because I want to create an Oracle Stored Procedure that will accept an XML string as an input parameter, prepare it, select from it, and then insert it into an Oracle table.
I have done this successfully in SQL server using the following as an example:
CREATE PROCEDURE [dbo].[Employee_INSERT]
bq. @INSERTRECORD XML
AS
BEGIN
bq. DECLARE @XDOC INT; \\ EXEC sp_xml_preparedocument @XDOC OUTPUT, @INSERTRECORD; \\ INSERT INTO [dbo].[REC_Employees] (
bq. bq. [EMPTITLE], \\ [EMPFNAME], \\ [EMPLNAME], \\ [EMPDEPTID], \\ [EMPBEGINDATE], \\ [EMPACTIVE], \\ [EMPDATEADDED]
bq. )
bq. SELECT
bq. bq. [EMPTITLE] = Title, \\ [EMPFNAME] = Firstname, \\ [EMPLNAME] = LastName, \\ [EMPDEPTID] = DepartmentID, \\ [EMPBEGINDATE] = StartDate, \\ [EMPACTIVE] = IsActive, \\ [EMPDATEADDED] = GETUTCDATE()
bq. FROM
bq. bq. OPENXML(@XDOC, '/EMPREC/Table', 2) \\ WITH (
bq. bq. Title VARCHAR(10), \\ FirstName VARCHAR(50), \\ LastName VARCHAR(50), \\ DepartmentID INT, \\ StartDate DATETIME, \\ IsActive BIT
bq. bq. );
bq. EXEC sp_xml_removedocument @XDOC;
END
I would sincerely appreciate any help in this regard!
PS - Please excuse the formatting!
Much Thanks!
regards
shalanAssuming your table is named DESTINATION
Name Null? Type
TITLE VARCHAR2(10)
FIRSTNAME VARCHAR2(50)
LASTNAME VARCHAR2(50)
DEPARTMENT NUMBER
STARTDATE DATE
ISACTIVE NUMBERYou can use a procedure like:
create or replace
procedure test (p_xml in xmltype)
is
begin
insert into destination
select title
, firstname
, lastname
, department
, to_date (startdate, 'yyyy-dd-mm hh24:mi:ss') startdate
, isactive
from (xmltable ('/EMPREC/Table' passing p_xml
columns title varchar2(5) path 'Title'
, firstname varchar2(10) path 'FirstName'
, lastname varchar2(10) path 'LastName'
, department number path 'Department'
, startdate varchar2(20) path 'StartDate'
, isactive number path 'IsActive'
) temp
end test;to create records in the table
Removed a unnecessary SELECT FROM DUAL...
Edited by: Alex Nuijten on Jan 19, 2009 2:24 PM -
Error while executing java stored procedure from a pl/sql procedure
We have a requirement where we need to execute JAVA code stored in an Oracle database (Java Stored Procedure). This code uses some JAR files which we have already loaded without any errors in the database.
The class file was also loaded in the database without any errors. But when we execute the method of this class (JAVA code), it gives the following error:
ORA-29532: Java call terminated by uncaught Java exception:
java.lang.NoClassDefFoundError
Is there any way of debugging the code and getting to know where exactly the problem is? Or, any tool/software available for doing the same.
Any pointers would be of great help!
Thanks in advanceHi Uday,
My guess is that there is a problem with your java stored procedure that is causing the "ExceptionInInitializer" error to be thrown. According to the javadoc:
is thrown to indicate that an exception occurred during
evaluation of a static initializer or
the initializer for a static variable
Since I didn't see any of your code in your post, I can't help you much more, I'm afraid. Perhaps if you would provide some more details, I may be able to help you some more. I think the following details would be helpful:
1. Complete error message and stack trace you are getting.
2. The section of your java code that you think is causing the problem.
3. Oracle database version you are using.
Good Luck,
Avi. -
Java stored procedure vs. PL-SQL vs. external java program
Hi,
I'm using a stored procedure for running a query and a few consequent updates. Currently I'm using Java stored procedure for that, which was my choice for simplicity on one hand, and running with the DB on the other.
In my tests, strangely enough it came out that running as java stored procedure was 3-4 times slower than running as a java program outside the database. I don't know how to explain this, and I wonder if switching to PL/SQL will improve the performance of the code.
Any experiences? recommendations?
Thanks,
DawgIn my tests, strangely enough it came out that running as java stored procedure was 3-4 times slower than running as a java program outside the database. I don't know how to explain this, and I wonder if switching to PL/SQL will improve the performance of the code.This isn't strange at all. See: Oracle's JVM (Aurora) is an independent Java Virtual Machine implementation, in accordance to specification. It implements all necessary parts of it (I think so). When you use an external JVM (I assume it's Sun's HotSpot JVM) you use completely different product. It is implemented in different way, it has many different code parts.
One of the biggest differences between Oracle's JVM and Sun's JVM is [Just-in-Time compiler|http://en.wikipedia.org/wiki/Just-in-time_compilation]. Oracle has implemented it only in the 11g version of database, i.e. 2 years ago, while Sun performed it back in 2000 and continues to improve it for the last 9 years. That would explain obvious differences between Java program inside and outside the DB: they are executed in absolutely different worlds. Diffs could be up to 10x times or more - that's not unusual.
If you are on 10g and want to compare performance of stored Java procedure vs external program, then you might use additional command-line instruction for external program to disable JIT:
-XintPS. I wouldn't use Java for your task - that's a total overkill. Use simple SP instead. -
Hi,
I have a problem to transfer a XML file content to a MS SQL database by a given/fixed stored procedure. I'm able to transfer the content of the file by using following method ...
hstmt = DBPrepareSQL (hdbc, EXEC usp_InsertReport '<Report> ..... </Report>');
resCode = DBExecutePreparedSQL (hstmt);
resCode = DBClosePreparedSQL (hstmt);
... but in this case I'm not able to fetch the return value of the stored procedure!
I have tried to follow the example of the stored procedure in the help documentation (DBPrepareSQL) but I miss a datatype for xml?!?
Any idea how to solve my problem?
KR Cake
Solved!
Go to Solution.After some additional trials I found a solution by calling the stored procedure in this way
DBSetAttributeDefault (hdbc, ATTR_DB_COMMAND_TYPE, DB_COMMAND_STORED_PROC);
DBPrepareSQL (hdbc, "usp_InsertReport");
DBCreateParamInt (hstmt, "", DB_PARAM_RETURN_VALUE, -1);
DBCreateParamChar (hstmt, "XMLCONTENT", DB_PARAM_INPUT, sz_Buffer, (int) strlen(sz_Buffer) + 1 );
DBExecutePreparedSQL (hstmt);
DBClosePreparedSQL (hstmt);
DBGetParamInt (hstmt, 1, &s32_TestId);
where sz_Buffer is my xml file content and s32_TestID the return value of the stored procdure (usp_InsertReport(@XMLCONTENT XML))
Now I face the problem, that DBCreateParamChar limits the buffer size to 8000 Bytes.
Any idea to by-pass this shortage??
Maybe you are looking for
-
How can I pass parameters from one process flow to another process flow?
How can I pass parameters from one process flow to another process flow (sub process) in warehouse builder? let me know the steps I have to do in warehouse builder. Thanks in advance, Kishan
-
How to set the default value of a LOV that is found in a view criteria
HI, I need to set the default value of an LOV that is found in a view criteria. I tried to set a groovy expression but unfortunately it wasn't read. i also tried to bind the LOV to a bind variable and set the value of the bind variable in the constru
-
"The system cannot find the path specified" error
Hi, Thanks for taking the time and reading. I had to update an old report that was made in CrystalReports. I copied the rpt files and pasted them into a csharp solution in VS 2010. The report structure is of a Main report and 6 subreports. I have to
-
Printing a PDF in booklet form
Is it possible to print a PDF document in a booklet form? I have a 28 page document that i'd like in A5 booklet, but can't find any options for booklet printing. Is this because my printer doesn't support booklet printing, or do you have to use speci
-
The FAQs says that full resolution will load to the icloud photo stream from my macbookpro, but that's not the case, it's a smaller version. Has this changed? It used to work at full resolution.