Re: More newbie questions on mass delete
- From: "Mark A. Parsons" <user@xxxxxxxxxxx>
- Date: Fri, 12 May 2006 19:33:07 GMT
Consider putting your query inside a proc:
1 - create proc in sybsystemprocs
2 - make sure proc name starts with 'sp_'
3 - pass @mytable as a parameter
4 - execute proc in desired database with 'exec <db_name>..sp_<proc_name> @mytable'
As for the resultant row count ... you could pass this back as a return code (return @rows), as an output parameter, or as a result set.
GWood wrote:
Thanks to everybody who has helped out so far. I am using some of R..
Verschoor's code to run dynamic sql in our 11.9.2 environment. The one
thing (ha!) I'm still having problems with is getting an accurate count of
rows impacted by DML e xecuted via this dynamic sql. I am not at liberty to
alter system procedures.
So I am thinking about trying to get a "before" and "after" count of table
rows. For my deletion project purposes, this should suffice. I have
scrounged up code similar to the following (and I realize it is statistics
dependent) :
select @rows = rowcnt(doampg)
from sysindexes idx, sysobjects obj
where idx.indid < 2 and idx.id = obj.id and obj.type = 'U'
and obj.name = @mytable
The issue I now have is that I need to run this programatically for many
databases in my environment. When I attempt to qualify the table names with
a database name, the query hurls with 'OAM page 47336 passed to rowcnt
function is an unallocated page in database 70.' Essentially it seems to
dislike the rowcnt function being used when accessing a non-current DB. I
have tried bringing back the "doampg" value and performing the rowcnt
locally, but it also generates the same error.
Anybody know how I can circumvent this, or have another idea on how to get
to a rowcount for a non-current DB table?
Tnx
Gary
- Follow-Ups:
- Re: More newbie questions on mass delete
- From: GWood
- Re: More newbie questions on mass delete
- References:
- More newbie questions on mass delete
- From: GWood
- More newbie questions on mass delete
- Prev by Date: More newbie questions on mass delete
- Next by Date: Re: More newbie questions on mass delete
- Previous by thread: More newbie questions on mass delete
- Next by thread: Re: More newbie questions on mass delete
- Index(es):
Relevant Pages
|
|