* Program: GenInsTrigger * Author: George Tasker * Date: July 29, 2002 - 3:54 PM * Purpose: Generates a trigger that * will insert the current datetime LPARAMETERS tcServer, tcDatabase, tcTable LOCAL lcuser, lcpassword,; oSQLSvr AS "SQLDMO.SQLServer",; lccrlf, lcheader, oDMO AS "SQLDMO.Database",; oTable AS "SQLDMO.Table",; lnlast, lni, a_fields, lcdeclare,; lnoffset, lcdeclare, lcfetch, lcloop,; lccursor, lctrigger,; oTrigger AS "SQLDMO.Trigger" lcuser = < username > lcpassword = < password > lccrlf = CHR(13) + CHR(10) * Create the header lcheader = "CREATE TRIGGER " + "tu_" + tctable + " ON [" + tctable + "]" + lccrlf lcheader = lcheader + "FOR UPDATE" + lccrlf + "AS" + lccrlf lctrigger = lcheader + 'IF NOT update(modifiedDate)' + lccrlf lctrigger = lctrigger + 'BEGIN' + lccrlf lctrigger = lctrigger + ' UPDATE ' + tcTable + lccrlf lctrigger = lctrigger + ' SET modifiedDate = getdate()' + lccrlf lctrigger = lctrigger + ' FROM ' + tcTable + ', inserted' + lccrlf lctrigger = lctrigger + ' WHERE ' + tctable + '.idColumn = inserted.idColumn' + lccrlf lctrigger = lctrigger + 'END' * Create the SQL Server reference oSQLSvr = CREATEOBJECT("SQLDMO.SQLServer") * Connect to the database oSQLSvr.Connect(tcServer, lcuser, lcpassword) * Get a reference to the database oDMO = oSQLSvr.Databases(tcDatabase) * Get a reference to the table oTable = oDMO.Tables(tcTable) * Get a reference to a trigger oTrigger = CREATEOBJECT('SQLDMO.Trigger') oTrigger.Name = 'tu_' + tcTable oTrigger.Text = lctrigger oTable.Triggers.Add(oTrigger) * All done, close up oSQLSvr.Close STORE NULL TO oSQLSvr, oTable, oDMO, oTrigger>I also have another question: I created my database at hand, I mean manually in the enterprise manager as I can't afford a Database design software. But I took the time to comment every table and every field. Is there any way to get that information and have a document of everuthing?