I knew about it, but the documentation discouraged me from using this approach. Take a look:
sp_spaceused – displays estimates of the number of data pages, space used by a specified table or by all tables in the current database, and the number of rows in the tables. sp_spaceused computes the rowtotal value using the rowcnt built-in function. This function uses a value for the average number of rows per data page based on a value in the allocation pages for the object. This method is very fast, but the results are estimates, and update and insert activity change actual values. The update statistics command, dbcc checktable, and dbcc checkdb update the rows-per-page estimate, so rowtotal is most accurate after one of these commands executes. Always use select count(*) if you need exact row counts.
What I’ve found out reading the forum post, is, that if you really, really, need an exact value in current moment, you should perform these just before ROW_COUNT():
EXEC sp_flushstats [Table]
UPDATE TABLE STATISTICS [Table]
Today, I’ve been checking if there are any videos on YouTube on Sybase ASE’s dbcc traceon usage and I’ve found this interesting video by Lester Leonares about a nice functionality to log user activity to a file:
(This video is a part of the SAP D&T Academy, definitely worth checking out.)
Since APT isn’t, for quite a long time, any more supported by Sybase, some applications needed to be converted/rewritten to other platforms. I’ve seen some code automatically converted from APT to PowerBuilder by AnyLEX (site unfortunately under construction).
If you happen to be stuck with some of your legacy code written in the APT, contact me, I can try to help.
Elegant Programming: The Art of Naming (Part 1)
— Give all entities mentioned in the code (DB tables, DB tables’ fields, variables, classes, functions, etc.) meaningful, descriptive names that make the code easily understood. The names should be so self-explanatory that it eliminates the need for comments in most cases.
Use the words per and by as often as possible – they really simplify a developer’s life. A variable’s name li_cows_per_farm is better than li_total_cows, and a function name uf_retrieve_city_by_country tells us more than uf_retrieve_city, especially if it doesn’t have parameters that supply the “by what” information…
I really like… not, reading through code where variables are named @var1, @aa, temporary tables #temp, #t1. When I need to touch such code, I have “a bad habit” of renaming those, re-indenting the code, if necessary, in case there are mixed tabs with spaces, unify them, basically leave the code in a little better shape than I’ve welcomed it.