Archive for February, 2013

Displaying the name of the table when using sp_MSforeachtable

February 27, 2013

sp_MSforeachtable is very handy in displaying the contents of tables.

Besides displaying the contents, also displaying the name of the table can be done with the ? variable surrounded by ”.  Notice that for each single ‘, two must be used:

declare @q1 varchar(1000) =

exec(”select ””?”” as [table_name]”)
declare @q varchar(1000)
set @q=”select top 10 * from ?”
exec(@q)’

EXEC sp_MSforeachtable @command1=@q1

Notes:

– If something doesn’t work, troubleshooting the contents of @q1 can be done with:

select @q1

-A filter can be added to the sp:

EXEC sp_MSforeachtable @command1=@q1,@whereand=’and object_id in (your_list_here) ‘

–the @whereand comes from:
select * from sys.objects where object_id in (your_list_here)

Advertisements

Transferring mail from Mac 10.4 to Mac 10.8.2

February 10, 2013

The process of transferring mail using Migration Assistant didn’t work.  It showed a message along the lines of “Upgrade Migration Assistant in the source Mac”.  I have not been able to upgrade the app.

Instead, I opened Mail for the first time in the new Mac and that created the necessary folders in the Mail folder (http://www.macinstruct.com/node/183).

Trying to display the Mail folder under the Library in order to copy and paste can be done with (http://osxdaily.com/2011/07/04/show-library-directory-in-mac-os-x-lion/):

Launch Terminal from Spotlight or Launchpad -> Utilities, and enter the following command to show or hide the directory:
chflags nohidden ~/Library/

The users Library folder will immediately become visible again. Reverting this back to the standard Lion setting is simple too:

This returns to the default setting of hiding the user Library directory:
chflags hidden ~/Library/

Changes take effect immediately again, and Library becomes invisible to the user.

After doing that, I copied the Mail folder from the old Mac into the Library with a name Mail_old.

I overwrote INBOX.mbox and Sent Messages.mbox in the  Mail/V2/POP-user@incoming.server  with the old contents.

Ensure you quit Mail.

Delete the Mail/V2/MailData/Envelope Index* to force Mail to reindex upon starting it again.  See https://discussions.apple.com/thread/3352228?start=0&tstart=0

Upon reopening Mail, the Mail Message  Import process gets started and the mail shows in the Inbox and Sent boxes.