Showing posts with label alter. Show all posts
Showing posts with label alter. 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

Friday, March 9, 2012

Get the InputGlobalVariables from a different package

I've been tasked with figuring out how to alter the version_id of an ExecutePackageTask programatically from a separate DTS package.

The ultimate goal is to have a "utility" DTS pack that
iterates through all the child packages within a given parent package, checks the systems tables to get the latest version_id, then assigns the latest versionid to the ExecutePackageTask. We feel this beats the heck out of opening the parent, opening each ExecutePackageTask, running through the randomly ordered list of Package Names and clicking on the updated package when a child package changes or a program is migrated to a new server.

My approach was to open the parent pack from an activex script in the utility DTS package, then iterate through the task collection looking only at ExecutePackage tasks, then check the versionid against the appropriate row in the sysdtspackages table and update the child package version_id if necessary.

I've only gotten as far as looking at the ExecutePackageTask properties and I'm stumped . . . I'm told that the object doesn't support the property or method, yet you can do this manually through a disconnected edit! Any thoughts?

Here's the code so far:
Function Main()

'create the target parent package object
Set objPackage = CreateObject("DTS.Package2")

'load the target parent package
objPackage.LoadFromSQLServer "PAMB","dts" ,"dts", DTSSQLStgFlag_UseTrustedConnection, , , ,"TESTME2"

'Create the task object
Set objTask = objPackage.Tasks

'Iterate through the tasks
For each objTask in objPackage.Tasks
if left(objTask.Name,29) = "DTSTask_DTSExecutePackageTask" then
msgbox objTask.Description
msgbox objTask.Versionid
end if
Next

Main = DTSTaskExecResult_Success

End Function

Thanks in advance,

PamClearly there are too many projects in my head right now . . .

Wednesday, March 7, 2012

Get Stored Procedure

I know you can alter and create stored procedures, but is there a way to select a stored procedure? I rewrote some stored procedures for a database and now I want to go and update all the sites using that database(copies), but first I want to make sure that there were no other changes. So what I want to do is to write a page that will get the current stored procedure, compare it to what it should be, and if they are the same only them update it. Is this at all possible?[YODA MODE]
query on sysobjects and syscomments, and the answer to your question you shall find.
[/YODA MODE]|||This code returns a checksum value on each database object:select sysobjects.id,
sysobjects.name,
sysobjects.type,
sum(cast(checksum(syscomments.text) as bigint)) Object_Checksum
from sysobjects
inner join syscomments on sysobjects.id = syscomments.id
group by sysobjects.id,
sysobjects.name,
sysobjects.typeIf the checksum value of the old object does not match the checksum value of the new object, then the object definition has changed.