system-procedures

Undocumented System Procedure 'sp_MSforeachtable' and the @whereand parameter

I'm attempting to use the undocumented system procedure sp_MSforeachtable. But I need to restrict the affected tables to those that start with "smp" and that are in the "dbo" schema. I was able to find how to find procedures that start with "smp". I simply do: sp_MSforeachtable @command1=' print ''?''', @whereand=' and name like ''smp%...

How to define a current user?

Is it possible to define a current user? I found a stored procedure 'sp_mgGetConnectedUsers'. It returns a result set with the only unique field 'Address'. How could I associate an executing query with such 'Address'. Please advice. Note: As far as I understand, another way to get the current user is to set a unique application Id fo...