Stored Procedures Triggered By State
Feb 16, 2005
I am interested in creating a stored procedure that will trigger a script if an insertion to a particular table is done. I have never done this before, so I was wondering if someone could share any advice.
Thanks.
View 14 Replies
ADVERTISEMENT
Jul 23, 2005
I want to know the differences between SQL Server 2000 storedprocedures and oracle stored procedures? Do they have differentsyntax? The concept should be the same that the stored proceduresexecute in the database server with better performance?Please advise good references for Oracle stored procedures also.thanks!!
View 11 Replies
View Related
Sep 30, 2006
Hi,
This Might be a really simple thing, however we have just installed SQL server 2005 on a new server, and are having difficulties with the set up of the Store Procedures. Every time we try to modify an existing stored procedure it attempts to save it as an SQL file, unlike in 2000 where it saved it as part of the database itself.
Thank you in advance for any help on this matter
View 1 Replies
View Related
Nov 6, 2007
Using SQL 2005, SP2. All of a sudden, whenever I create any stored procedures in the master database, they get created as system stored procedures. Doesn't matter what I name them, and what they do.
For example, even this simple little guy:
CREATE PROCEDURE BOB
AS
PRINT 'BOB'
GO
Gets created as a system stored procedure.
Any ideas what would cause that and/or how to fix it?
Thanks,
Jason
View 16 Replies
View Related
Jul 18, 2006
Hi All,
I have read the various posts regarding the thread abort issue.
I have a stored proc (CLR-C#) which makes and ldap call to a novell NDS tree and attempts to pull about 40k+ records which I would then insert into a sql server database.
I have set up all the requrements in terms of clr enabled etc...
I have written my class and I can run the sp when I limit the records returned. However when I go to grab all the records, (which takes some time), the sp craps out with the error message in the title of this post.
The assembly is running under unsafe permissions.
If I run the sp once, it works, then again and I may or may not get an 6522 (memory error). I added the search parameter to break down the records returned (so I return a's then b's etc...) . BTW: This works fine ouside SQL Server, I can run this as an ASP.Net app (I prototyped it with a test harness aspx page).
Basically what the class does is
connect to novel nds directorypull records based on search criteria (blank for all)dump records into datatableserialize datatable to xmlcall another sp to take xml and insert into tabledisconnect from treeAny comments/suggestions apreciated.
Thanks,
Stephen
Here is the class (editied to protect privacy):
using System;
using System.IO;
using System.Text;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlTypes;
using System.Data.SqlClient;
using Microsoft.SqlServer.Server;
using Novell.Directory.Ldap;
namespace EDSPullInSQLStoreProc
{
public class EDSPROC
{
[Microsoft.SqlServer.Server.SqlProcedure]
public static void EDSPull(bool IsProd, bool IsSecure, string searchParam)
{
//variable declarations
string __LADPHost_DEV = "xx.xx.xx.xx";
string __LADPHost_PROD = "xx.xx.xx.xx";
int __LADPPort_NonSecure = xxx;
int __LADPPort_Secure = xxx;
int __LDAPPort;
string __LDAPUserDN_DEV = "some string";
string __LDAPUserDN_PROD = "somestring";
string __LDAPUserDNPwd_DEV = "apassword";
string __LDAPUserDNPwd_PROD = "apassword";
LdapConnection oLDAPConn;
DataTable oDTEDSData = new DataTable("EDSUSER");
string strErrResponseMsg = "";
SqlPipe oSQLPipe = SqlContext.Pipe;
//connect to eds
try
{
oLDAPConn = new LdapConnection();
if (IsSecure)
{
oLDAPConn.SecureSocketLayer = true;
__LDAPPort = __LADPPort_Secure;
}
else
{
oLDAPConn.SecureSocketLayer = false;
__LDAPPort = __LADPPort_NonSecure;
}
if (IsProd)
{
oLDAPConn.Connect(__LADPHost_PROD, __LDAPPort);
oLDAPConn.Bind(__LDAPUserDN_PROD, __LDAPUserDNPwd_PROD);
}
else
{
oLDAPConn.Connect(__LADPHost_DEV, __LDAPPort);
oLDAPConn.Bind(__LDAPUserDN_DEV, __LDAPUserDNPwd_DEV);
}
}
catch (LdapException ldapEx)
{
oSQLPipe.Send("Error connecting to EDS: " + ldapEx.LdapErrorMessage.ToString());
return;
}
if (oLDAPConn != null)
{
oDTEDSData.Columns.Add("LastName");
...a bunch more columns
DataRow oRow;
//make the ldap query filling the datatable
LdapSearchConstraints oEDSSearchConstriants = new LdapSearchConstraints();
oEDSSearchConstriants.MaxResults = 0;
LdapSearchResults oEDSSearchResults = oLDAPConn.Search("somestring", LdapConnection.SCOPE_ONE, "cn=" + searchParam + "*", null, false, oEDSSearchConstriants);
LdapEntry oEDSEntry;
LdapAttribute oEDSAttrib;
while (oEDSSearchResults.hasMore())
{
try
{
oEDSEntry = oEDSSearchResults.next();
}
catch (LdapException e)
{
oSQLPipe.Send("EDS Pull error: Obtaining next record - " + e.LdapErrorMessage.ToString());
try
{
oLDAPConn.Disconnect();
}
catch
{
oLDAPConn = null;
}
return;
}
oRow = oDTEDSData.NewRow();
oEDSAttrib = oEDSEntry.getAttribute("sn");
if (oEDSAttrib != null)
{
oRow["LastName"] = oEDSAttrib.StringValue;
}
else
{
oRow["LastName"] = "";
}
...get more attributes etc
}//end while
if (oDTEDSData.Rows.Count > 0)
{
try
{
TextWriter oWriter = new StringWriter();
oDTEDSData.WriteXml(oWriter);
string strXML = oWriter.ToString();
strXML = strXML.Replace("'", "''");
using (SqlConnection oConn = new SqlConnection("context connection=true"))
{
oConn.Open();
SqlCommand oCmd = new SqlCommand("exec proc_BulkInsertEDSUsers '" + strXML + "','" + searchParam + "'", oConn);
oCmd.ExecuteNonQuery();
oSQLPipe.Send("EDS Pull complete.");
}
}
catch (Exception ex)
{
oSQLPipe.Send("An error has occurred. " + ex.Message.ToString() + "" + ex.InnerException.Message.ToString());
try
{
oLDAPConn.Disconnect();
}
catch
{
oLDAPConn = null;
}
return;
}
}
//close the ldap connection
try
{
oLDAPConn.Disconnect();
}
catch
{
oLDAPConn = null;
}
}
}
}
}
View 9 Replies
View Related
Mar 17, 2008
Hello, i have a problem regarding stored procedures and view server state.
I have an application with a lot of stored procedures, one of them checks data of the connected users.
In SQL 2000 i had no problem getting this information, but in SQL server 2005 i do.
my stored procedure looks like this:
ALTER PROCEDURE [dba].[applsp_GetConnectionInfo]
(
@DBName varchar(100)
)
WITH EXECUTE AS OWNER AS
BEGIN
SET NOCOUNT ON
DECLARE @sCollationMaster VARCHAR(128);
DECLARE @sSqlString VARCHAR(900);
-- Determine collation from master database because collation from master and ultimo database may differ
SELECT @sCollationMaster = CAST(databasepropertyex('master', 'Collation') AS VARCHAR);
SET @sSqlString =
'SELECT max(status) AS Status, max(isnull(SCISUSENAME, ''ULTIMOLOGIN'')) AS Login
, MAX(Rtrim(Rtrim(convert(varchar(255), nt_domain)) + nt_username)) AS NTUser
, max(Rtrim(hostname)) AS Host, MAX(Rtrim(program_name)) AS Program
FROM master.dbo.sysprocesses JOIN dba.SCONNECTIONINFO on SCISPID = CAST(spid AS VARCHAR)
AND ( SCISUSENAME = ISNULL(loginame, '''') COLLATE ' + @sCollationMaster + ' OR ISNULL(loginame, '''') = ''ULTIMOLOGIN'')
WHERE ...... AND DB_NAME(dbid) = ''' + @DBName + '''
GROUP BY hostprocess
ORDER BY Login
';
EXEC(@sSqlString);
END
I've granted view server state permissions to my user 'dba' which is the db_owner.
When i execute the query in the stored procedure seperatly as dba i get all the info i need, but when i execute the stored procedure i don't see anything.
I seem to have the same problem with sp_who2
Executing it gives me information about everyone but when i put in a stored procedure like this:
alter procedure test
with execute as owner as
begin
EXEC sp_who2
end
I just see information about myself
View 5 Replies
View Related
Dec 14, 1998
I've setup alerts and an operator to email on a particular event code.
I can successfully test the operator. (It e-mails fine)
The problem I am having is that despite having a particular event
log to the NT application log, no SQL Alert is triggered.
I've tried logging to the NT Application log, as well as the SQL errorlog.
The SQLExecutive is running.
Thanks in advance.
John
View 1 Replies
View Related
Aug 11, 2006
Hi guys,
Hope you are all well.
I am trying to set up a 'SQL Server event alert' that will 'net send' a warning message to one of the Operators that have been set-up on our SQL Server.
The alert has been configured to act on severity level '009 - User Defined', for all databases.
I have created a user defined system message with a severity level '9' on the sysmessages table.
EXEC sp_addmessage 80000, 9, 'My User Defined Message'
...and I have raised this error on our SQL Server.
RAISERROR(80000, 9, 1) WITH LOG
The error message is being generated in the SQL Server Log file, but for some reason my Alert does not appear to fire off the 'net send' event.
The operator is 'available to receive notifications', and I have tested the 'net send' command successfully.
Does anyone know why this Alert might not be sending a message with the 'net send' command?
Thanks in advance,
Kevin
View 1 Replies
View Related
Apr 29, 2008
How do I search for and print all stored procedure names in a particular database? I can use the following query to search and print out all table names in a database. I just need to figure out how to modify the code below to search for stored procedure names. Can anyone help me out?
SELECT TABLE_SCHEMA + '.' + TABLE_NAME
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_TYPE = 'BASE TABLE'
View 1 Replies
View Related
Jun 13, 2007
Seems like I'm stealing all the threads here, : But I need to learn :) I have a StoredProcedure that needs to return values that other StoredProcedures return.Rather than have my DataAccess layer access the DB multiple times, I would like to call One stored Procedure, and have that stored procedure call the others to get the information I need. I think this way would be more efficient than accessing the DB multiple times. One of my SP is:SELECT I.ItemDetailID, I.ItemDetailStatusID, I.ItemDetailTypeID, I.Archived, I.Expired, I.ExpireDate, I.Deleted, S.Name AS 'StatusName', S.ItemDetailStatusID, S.InProgress as 'StatusInProgress', S.Color AS 'StatusColor',T.[Name] AS 'TypeName', T.Prefix, T.Name AS 'ItemDetailTypeName', T.ItemDetailTypeID FROM [Item].ItemDetails I INNER JOIN Item.ItemDetailStatus S ON I.ItemDetailStatusID = S.ItemDetailStatusID INNER JOIN [Item].ItemDetailTypes T ON I.ItemDetailTypeID = T.ItemDetailTypeID However, I already have StoredProcedures that return the exact same data from the ItemDetailStatus table and ItemDetailTypes table.Would it be better to do it above, and have more code to change when a new column/field is added, or more checks, or do something like:(This is not propper SQL) SELECT I.ItemDetailID, I.ItemDetailStatusID, I.ItemDetailTypeID, I.Archived, I.Expired, I.ExpireDate, I.Deleted, EXEC [Item].ItemDetailStatusInfo I.ItemDetailStatusID, EXEC [Item].ItemDetailTypeInfo I.ItemDetailTypeID FROM [Item].ItemDetails IOr something like that... Any thoughts?
View 3 Replies
View Related
May 13, 2008
Greetings:
I have MSSQL 2005. On earlier versions of MSSQL saving a stored procedure wasn't a confusing action. However, every time I try to save my completed stored procedure (parsed successfully ) I'm prompted to save it as a query on the hard drive.
How do I cause the 'Save' action to add the new stored procedure to my database's list of stored procedures?
Thanks!
View 5 Replies
View Related
Aug 2, 2004
Hello
If I have a trigger for INSERT and DELETE, how do I know what action was executed ??
I prefer not to split the trigger to one for each action, because the the procedure for both is almost the same.
Another question, How can I know what records were updated? I need to concatenate the ID/ID's to the SQL in the procedure.
Thanks,
Inon.
View 2 Replies
View Related
Aug 8, 2007
I've been studying/experimenting with the replication features and though the Updating Susbcribers Replication Model was the answer to my data environment.
What we want: We have a live server (Publisher) that'll serve content to our users, but we want an "offline/data entry" server (Subscriber) that'll pretty much have the exact same data as the live server for data entry and validation purposes. Changes and inserts would be done on the Subscriber locally, vetted through, and once done, it'd be updated to the Publisher.
I've managed to get some semblance of the above working, but the updates are nearly instantaneous. Which means that changes/inserts that may be erroneous on the subscriber machine would almost always be seen on the publisher machine before our operations can do anything about it.
Is there a way to configure the replication process to hold off until the admin triggers it? Or am I using the wrong feature?
View 4 Replies
View Related
Aug 27, 2007
Hi,
I am developing desktop application with SQL Server 2005 in C#. I need your help. My Question is "How to notify a Database trigger is executed thru C# application?".
Now I am going to explain clearly. I have a table "Employee" and I created one trigger (it may be INSERT/UPDATE/DELETE) for that table. Then I created a C# application to show a msg box when that table is modified. Now my question is If that table is modified a message box will be shown. I know about trigger (If trigger assigned table is modified that trigger will automatically executed.) But how do i know that trigger is executed thru a C# application. Please send your suggestion or links.
Thanx,
GANESAN MURUGESAN.
View 9 Replies
View Related
Oct 24, 2007
How do I make an event to fire for every 100 rows? I have set default buffermaxrows as 100, so I expect SSIS to write to the destination after every 100 rows and during that time I believe OnPipelineRowsSent would be fired.
But in my case, it write around 350+ rows and OnPipelineRowSent is fired only 3 times (350+350+350). Is there anything else I can do to fire this event for every 100 rows or its not possible?
Thanks
View 15 Replies
View Related
Apr 7, 2006
We recently upgraded to SQL Server 2005. We had several stored procedures in the master database and, rather than completely rewriting a lot of code, we just recreated these stored procedures in the new master database.
For some reason, some of these stored procedures are getting stored as "System Stored Procedures" rather than just as "Stored Procedures". Queries to sys.Objects and sys.Procedures shows that these procs are being saved with the is_ms_shipped field set to 1, even though they obviously were not shipped with the product.
I can't update the sys.Objects or sys.Procedures views in 2005.
What effect will this flag (is_ms_shipped = 1) have on my stored procedures?
Can I move these out of "System Stored Procedures" and into "Stored Procedures"?
Thanks!
View 24 Replies
View Related
Apr 23, 2008
Hello friends......How are you ? I want to ask you all that how can I do the following ?
I want to now that how many ways are there to do this ?
How can I call one or more stored procedures into perticular one Stored Proc ? in MS SQL Server 2000/05.
View 1 Replies
View Related
Mar 26, 2008
Hello
I'm start to work with SSIS.
We have a lot (many hundreds) of old (SQL Server2000) procedures on SQL 2005.
Most of the Stored Procedures ends with the following commands:
SET @SQLSTRING = 'SELECT * INTO ' + @OutputTableName + ' FROM #RESULTTABLE'
EXEC @RETVAL = sp_executeSQL @SQLSTRING
How can I use SSIS to move the complete #RESULTTABLE to Excel or to a Flat File? (e.g. as a *.csv -File)
I found a way but I think i'ts only a workaround:
1. Write the #Resulttable to DB (changed Prozedure)
2. create data flow task (ole DB Source - Data Conversion - Excel Destination)
Does anyone know a better way to transfer the #RESULTTABLE to Excel or Flat file?
Thanks for an early Answer
Chaepp
View 9 Replies
View Related
Dec 26, 2006
HelloThe problem is need to find out the querry that has updated or insertedinto the table and in turn 'Triggered the Trigger'. I have the username, the machine name, Application name, but not the query. The updateis not desired and the application is doing it but the applicationbeing so large we are unable to pin-point the code which is doing thedammage.Pls help!RegardsAnubhav
View 1 Replies
View Related
Oct 22, 2001
I would like to know how to config SQL Server 2000 Alert to be triggered by new file creation (i.e. txt file).
Maybe by monitoring windows 2000 log file (not sure)??
Any help or suggestion will be highly appreciated.
View 2 Replies
View Related
Sep 23, 2007
I have a child package which is executed several times within the same SSIS ETL. I have placed a break point on one of the child package's tasks, set to trigger on a PreExecute() event. The first time the child package is invoked, the breakpoint is triggered. However, on each successive invocation the breakpoint is ignored. Does anybody know if this behaviour is normal? Thanks in advance!
View 1 Replies
View Related
Apr 16, 2008
i have a package which logs to a table the status of its execution. i wonder if there is a way to trigger an event when package execution is terminated.
View 3 Replies
View Related
Nov 16, 2007
How is cross platform recognition triggered in the process?
View 2 Replies
View Related
Jul 3, 2007
Hi,
I have a job in SQL Server agent with 199 SSIS steps and growing. In the job log only 99 steps are shown, which is a problem if a step higher than 99 fails to run. I need the steps to run in sequence and preferable would like to split the job into several jobs each containing no more than 99 steps. The only thing I don't know is if it is possible to have the next job in sequence start only when the previous job has finished.
Does anyone know if this is possible, and if so how it is done?
Many thanks,
Paul
View 4 Replies
View Related
Jun 16, 2007
Hi,
Do you know how to write stored procedures inside another stored procedure in MS SQL.
Create procedure spMyProc inputData varchar(50)
AS
----- some logical
procedure spMyProc inputInsideData varchar(10)
AS
--- some logical
--- go
-------
View 5 Replies
View Related
May 8, 2008
I am writing a set of store procedures (around 30), most of them require the same basic logic to get an ID, I was thinking to add this logic into an stored procedure.
The question is: Would calling an stored procedure from within an stored procedure affect performance? I mean, would it need to create a separate db connection? am I better off copying and pasting the logic into all the store procedures (in terms of performance)?
Thanks in advance
John
View 5 Replies
View Related
Nov 1, 2007
Hi all - I'm trying to optimized my stored procedures to be a bit easier to maintain, and am sure this is possible, not am very unclear on the syntax to doing this correctly. For example, I have a simple stored procedure that takes a string as a parameter, and returns its resolved index that corresponds to a record in my database. ie
exec dbo.DeriveStatusID 'Created'
returns an int value as 1
(performed by "SELECT statusID FROM statusList WHERE statusName= 'Created')
but I also have a second stored procedure that needs to make reference to this procedure first, in order to resolve an id - ie:
exec dbo.AddProduct_Insert 'widget1'
which currently performs:SET @statusID = (SELECT statusID FROM statusList WHERE statusName='Created')INSERT INTO Products (productname, statusID) VALUES (''widget1', @statusID)
I want to simply the insert to perform (in one sproc):
SET @statusID = EXEC deriveStatusID ('Created')INSERT INTO Products (productname, statusID) VALUES (''widget1', @statusID)
This works fine if I call this stored procedure in code first, then pass it to the second stored procedure, but NOT if it is reference in the second stored procedure directly (I end up with an empty value for @statusID in this example).
My actual "Insert" stored procedures are far more complicated, but I am working towards lightening the business logic in my application ( it shouldn't have to pre-vet the data prior to executing a valid insert).
Hopefully this makes some sense - it doesn't seem right to me that this is impossible, and am fairly sure I'm just missing some simple syntax - can anyone assist?
View 1 Replies
View Related
Oct 5, 2015
I have a Send Mail task as part of a validation process in a OnPostExecute event handler. All tasks preceding the Send Mail task get triggered and show green check mark next to them, but, for some reason, Send Mail task never gets one.
I checked the Execution Results tab and it doesn't show any indication of Send Mail task executing as a final step.
I checked the SMTP server configuration and did some test using localhost. I'm able to send as configured while using anonymous credentials.
View 4 Replies
View Related
Oct 24, 2006
My question is it possible to send a report developed in reporting services via email as either a attachment or imbedded in the email, from an insert trigger placed on a table in sql.
If so could you please help with the string that would be need to achieve this.
The report will need to have one or two parameters passed to it from the table.
The report is built and working through reporting services already. I was impressed with the subscription services that reporting services has in place and would like to utilise the reports further by auto emailing out when a new record is placed in the table. To be sent out either as an attachment or imbedded in the email it self.
Thanks for any assistance in advance
David
View 2 Replies
View Related
Mar 26, 2015
I have multiple task flows with precedence constraints and i have changed the constraint as completion to execute the package even though there is failure in one of the tasks in the package but every time the send mail success is executed instead of Send mail Failure task.
View 0 Replies
View Related
Aug 3, 2006
The 2.0 version of ASPSTATE is slightly different than the 1.1 version in that one table has one additional column and another table uses a different data type and size for the key. The 2.0 version also has a couple additional stored procedures.
We'd like to manage just one session state database if possible so we're trying to figure out if Microsoft supports using the new schema for 1.1 session state access (it seems to work, but our testing has been very light).
Is there any official support line on this? If not, can anyone comment on whether or not you'd expect it to work and why?
Thanks.
View 1 Replies
View Related
May 15, 2008
i have created the folowing function but keep geting an error.
Only functions and extended stored procedures can be executed from within a function.
Why am i getting this error!
Create Function myDateAdd
(@buildd nvarchar(4), @avdate as nvarchar(25))
Returns nvarchar(25)
as
Begin
declare @ret nvarchar(25)
declare @sqlval as nvarchar(3000)
set @sqlval = 'select ''@ret'' = max(realday) from (
select top '+ @buildd +' realday from v_caltable where realday >= '''+ @avdate +''' and prod = 1 )a'
execute sp_executesql @sqlval
return @ret
end
View 3 Replies
View Related
Sep 26, 2007
We have mirroring setup for 5 dbs, 4 of which are synchronized and 1 which is in "synchronizing" state on the principal and "restoring" state on the mirror. Mirroring for all dbs has been working fine for the past several months and we have a witness that has allowed automatic failover in the past without problems.
This database has several bulk inserts performed throughout the day and am sure there is some latency due to the size of these transactions.
Not sure as to why this is happening all of a sudden, but the db in question has been in this state for the past 12 hrs. I checked the mirroring status on the principal and it states that it is "synchronizing: data is being transferred from principal to mirror", but the mirror server states that db is in "restoring" state. Can anyone suggest as to how I can get the database on the mirroring server to get back to "mirror, synchronizing/restoring..." state? Or suggest on how I can troubleshoot this?
Thanks in advance.
View 3 Replies
View Related