Home Home    Forum    Blog    Feed your aggregator (RSS 2.0)

The Johnnynine Weblog - Tuesday, July 12, 2005
A weblog by Johnny Hughes
 
 Tuesday, July 12, 2005

I downloaded the latest dasblog source code, compiled it, and upgraded my version. Let's just hope I copied over the correct files... nothing more, nothing less.

Tuesday, July 12, 2005 11:19:45 PM (US Mountain Standard Time, UTC-07:00)  #    Comments [0]   My Blog  | 

I can’t tell you how many times I’ve done an import and ended up with the wrong database owner.  Use this following script to change the owner on all tables in a database.

In the sql below, set the @oldowner and @newowner variables appropriately.

DECLARE @oldowner sysname, @newowner sysname, @sql varchar(1000)

SELECT
  @oldowner = 'OLD_OWNER',
  @newowner = 'dbo',
  @sql = '
  IF EXISTS (SELECT NULL FROM INFORMATION_SCHEMA.TABLES
  WHERE
      QUOTENAME(TABLE_SCHEMA)+''.''+QUOTENAME(TABLE_NAME) = ''?''
      AND TABLE_SCHEMA = ''' + @oldowner + '''
  )
  EXECUTE sp_changeobjectowner ''?'', ''' + @newowner + ''''

EXECUTE sp_MSforeachtable @sql

(I found this somewhere on the internet some time ago but have lost it's reference.)

Tuesday, July 12, 2005 5:09:15 PM (US Mountain Standard Time, UTC-07:00)  #    Comments [0]   Database | Sql Server  | 

Here is the lifecycle of a Windows Service from .Net

--Clicked Start from gui
Main()
Service1() Constructor
InitializeComponent()
OnStart()
--END Clicked Start from gui


--Clicked Restart from gui (looks just like clicking stop and then start)
OnStop()
Dispose()
Main()
Service1() Constructor
InitializeComponent()
OnStart()
--ENDClicked Restart from gui (looks just like clicking stop and then start)


--Clicked Stop from gui
OnStop()
Dispose()
--END Clicked Stop from gui


--Ran from VS.NET by hitting "Play" button and only calling "(new Service1()).OnStart(args);" from Main().
Main()
Service1() Constructor
InitializeComponent()
OnStart()
Dispose()
--END Ran from VS.NET by hitting "Play" button and only calling "(new Service1()).OnStart(args);" from Main().

Tuesday, July 12, 2005 4:47:35 PM (US Mountain Standard Time, UTC-07:00)  #    Comments [0]   .NET  | 

To retrieve an unordered set of rows:

SELECT * FROM orders WHERE rownum < 2 ;

To retrieve rows of an ordered result set:

SELECT o.* FROM (SELECT * FROM orders ORDER BY orderid) o
WHERE rownum < 2 ;

This is because rownum is assigned to the result set when the records are retrieved and before they are sorted.

Note: In Sql Server, use the TOP keyword.

Tuesday, July 12, 2005 4:42:51 PM (US Mountain Standard Time, UTC-07:00)  #    Comments [0]   Database | Oracle  | 

Sometimes (especially when running web applications) it's nice to see how many open connections you have to your database. Use this select statement to get them (ignore SID of <="5).

select * from v$lock

Cross reference SID with:

select * from v$session where sid=1234

Tuesday, July 12, 2005 4:34:31 PM (US Mountain Standard Time, UTC-07:00)  #    Comments [0]   Database | Oracle  | 
Copyright © 2009 Johnny Hughes. All rights reserved.
DasBlog 'Portal' theme by Johnny Hughes.