Showing posts with label perform. Show all posts
Showing posts with label perform. Show all posts

Friday, March 23, 2012

how to determine if a stored proc is running

I need to determine whether a stored procedure is executiing and perform
various steps dependent on the state of the procedure in question (i.e.,
determined from sysprocesses.status). I know I can get the listing of
active commands sysprocesses.cmd (from the master table, sysprocesses),
but this doesn't give me the _stored procedure_ name, as it appears in
Enterprise Manager when you click on the ProcessID and it gives the
"Last TSQL Batch..." Where exactly is this information is this stored?
Somewhere, I assume, in MDDB?
TIA!
gms--Greg M. Silverman wrote:
> I need to determine whether a stored procedure is executiing and
> perform various steps dependent on the state of the procedure in
> question (i.e., determined from sysprocesses.status). I know I can get
> the listing of active commands sysprocesses.cmd (from the master
> table, sysprocesses), but this doesn't give me the _stored procedure_
> name, as it appears in Enterprise Manager when you click on the
> ProcessID and it gives the "Last TSQL Batch..." Where exactly is this
> information is this stored? Somewhere, I assume, in MDDB?
> TIA!
> gms--
>
okay, looks like DBCC INPUTBUFFER (pid) gives me what I need.
gms--

Friday, February 24, 2012

How to delete and then add to the bottom of the list

Hi,

I have a record in the Database. I want to perform some functions on the record and then place that record at the end of list.

How can I achieve that ??are you trying to do this from a stored proc ? if so you can get the columnvalues into variables and then insert back into the db..

you can also use the "deleted" table to get the values...but there are some limitations i believe...you can check the documentation for using the deleted table..

HTH|||Data in SQL is, by definition, not sorted unless you specify how you want it sorted. So, if you want a record to be at the end of aset of records, you need to specify an ORDER BY that will put it at the end. If you always want the last record modified to be at the end, you might consider adding a LastModified datetime field to the table, putting in an UPDATE trigger that will set that field to the current date/time (calling GetDate will retrieve the current system date/time), and then have and ORDER BY LastModified on your SELECT command.