Showing posts with label triggers. Show all posts
Showing posts with label triggers. Show all posts

Monday, March 19, 2012

get triggers latest update date

Is there a way in MSSQL 2000 to get trigger's latest update date?
sysobject table only has creation date of a trigger and I've been using ALTER TRIGGER command to modify it.
Thanks,
IgorUnfortunately, no. You can't get the last modified date for any SQL Server objects. You might instead do a DROP and CREATE when modifying your triggers.

Terri

Get trigger information

Hi Freinds,
SQL 2000
I need to find out that if any of triggers on my database has a word
"dup_order" in it
is ther eany schema lime infromation_schema.column_name that I can use to
scan all triggers and find out which one contains the word?
Thanks in advance,
PatYou can search syscomments system table which has the source code for all
the user defined triggers in your database.
Anith|||SELECT OBJECT_NAME(id)
FROM syscomments
WHERE OBJECTPROPERTY(id, 'IsTrigger')=1
AND [text] LIKE '%dup[_]error%'
Because triggers that are > 8000 characters will span multiple rows, and
since the text "dup_order" might only appear in such a position that it
straddles rows, a better way might be to have all your triggers scripted out
using Enterprise Manager, and do a search within the output.
I am not sure exactly how SQL Server internally maps a trigger to belong to
a certain table (it may be embedded in the hideous ctext column somehow?).
You can certainly read/parse the ON section of the trigger, and that will
tell you, but doing so programmatically might not be 100% effective.
In SQL Server 2005 we will have more foolproof methods for scanning the
entire definition of an object, rather than deal with this 8000-character
chunk limitation.
"Patrick" <patriarck@.gmail.com> wrote in message
news:uU1sk%230oFHA.3304@.tk2msftngp13.phx.gbl...
> Hi Freinds,
> SQL 2000
> I need to find out that if any of triggers on my database has a word
> "dup_order" in it
> is ther eany schema lime infromation_schema.column_name that I can use to
> scan all triggers and find out which one contains the word?
> Thanks in advance,
> Pat
>|||To overcome the 4000 characters limitation, use the following procedure
to search for a string in all views, procedure, triggers and UDF-s:
CREATE PROCEDURE sp_findtext(@.Text nvarchar(256))
AS
SET @.Text=Replace(Replace(Replace(@.Text,
'[', '[[]'), '%', '[%]'), '_', '[_]')
SELECT name, xtype FROM (
SELECT id FROM syscomments WHERE text LIKE '%'+@.Text+'%'
UNION
SELECT c1.id FROM syscomments c1
INNER JOIN syscomments c2 ON c1.id=c2.id AND c1.colid=c2.colid-1
WHERE SUBSTRING(c1.text,3001,1000)+LEFT(c2.text,1000)
LIKE '%'+@.Text+'%'
) U INNER JOIN sysobjects o ON u.id=o.id
ORDER BY xtype, name

> I am not sure exactly how SQL Server internally maps
> a trigger to belong to a certain table
See the parent_obj column in the sysobjects table.
Razvan

Sunday, February 26, 2012

Get return value from stored procedure and trigger

Hello there,

I searched for answers to the above topic, but could not find what I want. My stored procedures and triggers are returning a message based on the result, mostly error messages. How can I get that message using ASP.Net? Should I use an output parameter?

Thank you for your help.

Use this type dataset generator it will do it for you. you select which sp to use with a gui and paf you get a nice typed dataset class.

Enjoy I love it greatly

SQL Stored Procedure Wrapper & Typed DataSet Generator for .NET...

DBHelper is a small tool that will generate either a source file or a compiled... No problem forDBHelper, just a few clicks and you a have all the methods...
www.codeproject.com/cs/database/dbhelper.asp

|||

Joel,

Thank you for the reply and a looking great tool. I will try it. I am not sure thought if it will answer, but trust you.

Another way I just found is that using Exception class in an event in .Net. For example, if you delete a row in a gridview and trigger is fired for some reason and raises an error, it is passed to theGridViewDeletedEventArgs.

So you can that message withGridViewDeletedEventArgs.Exception.Message. You can do it GridView1_RowDeleted() event.

I hope this helps someone like me.Wink