May 6, 2009

Attunity Oracle-CDC for SSIS

SQL 2008 Enterprise Edtion has a nice feature "change data capture"(CDC) which would reduce a lot of efforts when dealing with SCD2. However, your SQL 2005 may have to stay in production for a long while or you may not have 2008 Enterprise Edition, and you need to extract data from Oracle database. Here is a good news for you.

Attunity provide a simple solution for replicating and integrating Oracle data efficiently and in real-time using SSIS.

The following information is from Attunity:
"Attunity Oracle-CDC for SSIS addresses the key challenges that data integration teams face in addressing business and IT requirements. Using it, you can:

  • Simplify and accelerate CDC implementation
  • Deliver real-time information
  • Design efficient data integration solutions
  • Leverage existing SQL Server investments
  • Reduce resources and costs

"

More info can be found in its website
http://www.attunity.com/oracle_cdc_for_ssis


Although the tool is not free, I would like to try its trail version whenever I have an opportunity.

unable to update McAfee VirusScan Enterprise 8.5.0i

One day in the early April, I found my McAfee could not do an update.
Error message said McAfee Framework Service wasn't running. Actually it disappeared from Services list.

McAfee was reinstalled successfully with Framework Service, however it still was unable to connect the server to do an update.

After I compared a working copy of McAfee on another PC, I found out SiteMapList.xml didn't exist on my Windows XP - C:\Documents and Settings\All Users\Application Data\McAfee\Common Framework\.

My Vista had the same issue as well. The location is C:\ProgramData\McAfee\Common Framework

After SiteMapList.xml was copied over, it has been working well since then.

Apr 13, 2009

Issues to access SQL Server in Oracle SQL Developer

1. Failed when tried to connect to a SQL server.

Error Message: Status: Failure -I/O Error: SSo Failed: Native SSPI library not loaded. Check the java.library.path system property.

Fix: Copy \x86\SSO\ntlmauth.dll to \jdk\jre\bin

2. How to connect a named SQL server instance.

In SQLServer tab:

Hostname:
Port: /;instance=

Ex: 1433/EDW_SA;instance=edw_dev

Seems it(1.5.4) doesn't support schema.

Feb 20, 2009

SQL 2005 installation failure on XP SP3

SQL 2005 and management studio tool cannot be installed on XP with SP3 applied.

Problem: MSXML 6.0 sp2 backward compatibility issue.

Error: Product: MSXML 6 Service Pack 2 (KB954459) -- Configuration failed.

Workaround:

1. uninstall msxml 6.0 sp2. If cannot, remove its entry in Registry.
2. Before removing it from Registry, do a backup first.
3. SQL 2005 should be able to be installed successfully.
4. patch SQL to the latest SP.
5. install MSXML 6.0 SP2.

Also refer to the following post:
http://social.msdn.microsoft.com/Forums/en-US/sqlsetupandupgrade/thread/97c58e05-c61b-4f29-8507-f83f437c6f1d/

Feb 11, 2009

TDWI Search Plugin for Mozilla Firefox


<[[CDATA

]]>

TDWI Search Plugin Install TDWI Search Plugin to search the TDWI.org site.

Jun 3, 2008

"KILLED/ROLLBACK" SQL Server Process Never Ends

You may see a killed SQL server process marked as "KILLED/ROLLBACK", but did not disappear from SQL Sevrer forever. Seems lots of people by doing restart the server or SQL service to clean up this issue. If your case is similar to mine, you may not need to do that again.

My Case:

A job was calling an external program, ex. winzip. It could not be finished as winzip registration file was missing.

After killing SQL process by issuing kill Command.

The process was marked as "KILLED/ROLLBACK", however it could not exit after a day.

Check the status: kill 463 with statusonly

SPID 463: transaction rollback in progress. Estimated rollback completion: 100%. Estimated time remaining: 0 seconds.


My Workaround:

In this case, I looked at the process in Windows level, I saw a winzip.exe was still running. Of course first I isolated no winzip was using. I killed winzip OS process, the hung SQL process exited from SQL Server automatically.

My Environment:

SQL Server 2000 SE SP4
Windows Server 2003 R2

May 26, 2008

DB document tool - SqlSpec

SqlSpec is from Elsasoft. It works well for SQL Server, better than SQL Doc, SQL Document Tool according to my evaluation.
However, you may not see information you are interested in Oracle, but still good in the schema level.
Here is the link. You can download an evaluation version for your trial.
just $149 for a single user, I think it is pretty worth.
http://www.elsasoft.org/


Examples of Connection String:
For SQL Server
server="serverName\instanceName"; database=dbName; user id=userName; pwd=yourPassword
For Oracle
Provider=OraOLEDB.Oracle;Data Source=tnsName;User Id=userName;Password=yourPassword

May 16, 2008

nmefwmi.exe issue in Oracle 11g on Vista

A window keeps pop-up saying "nmefwmi.exe has stopped working".

It is a known bug in Oracle, should be fixed in 11.1.0.7 release according to metalink.

Suggested Workaround prior to 11.1.0.7:

Check Compatibility in properties of setup.exe to "Run this program as a administrator".

May 15, 2008

Get User-defined Database Objects in MS SQL

I was trying to get all user-defined objects in SQL Server.
And tried to make it compatible with 2000,2005 and 2008.

Seems it wasn't easy as in Oracle, especially for stored procedures and functions. If you know a way to distinguish user-defined procedure and system procedure, please share.

select count(*) as 'UserTables'
from sysobjects
where type in ('U')

select count(*) as 'UserIndexes'
from sysindexes i
INNER JOIN sysobjects AS o ON i.id=o.id
where o.type='U'

select count(*) as 'UserTriggers'
from sysobjects o1
INNER JOIN sysobjects AS o2 ON o1.parent_obj=o2.id
where o1.type in ('TR', 'TA')
AND o2.TYPE='U'

select count(*) as 'UserViews'
from sysobjects
where type in ('V')
and name not like 'sys%'

select count(*) as 'StoredProcedures'
from sysobjects
where type in ('P','PC','X')

select count(*) as 'Functions'
from sysobjects
where type in ('FN','FS','FT','TF','AF','IF')


Reference: sysobjects.type


Common Object Types in SQL 2000, 2005 and 2008

C = CHECK constraint
D = DEFAULT (constraint or stand-alone)
F = FOREIGN KEY constraint
FN = SQL scalar function
IF = SQL inline table-valued function
P = SQL stored procedure
PK = PRIMARY KEY constraint
S = System base table
TF = SQL table-valued-function
TR = SQL DML trigger
U = Table (user-defined)
UQ = UNIQUE constraint
V = View
X = Extended stored procedure

Common Object Types in SQL 2005 and 2008

AF = Aggregate function (CLR)
FS = Assembly (CLR) scalar function
FT = Assembly (CLR) table-valued function
IT = Internal table
PC = Assembly (CLR) stored procedure
R = Rule (old-style, stand-alone)
RF = Replication-filter-procedure
SN = Synonym
SQ = Service queue
TA = Assembly (CLR) DML trigger

New Object Types in SQL 2008

PG = Plan guide

May 12, 2008

SQL Server 2000 Back Up falied to shared file system

Invalid Path when specifying BackUp location to a shared file system in SQL Server 2000.

Two things may need to be checked:

1. If SQL Server and Agent services are running under a domain service account.

I encountered this situation. After changing the services from local system to the designated domain account. The backup was successful.

2. Verify if domain account has the right permissions on the shared folder.

May 8, 2008

How Data Got Moved and Purged in MOM 2005 Database

1. Transfer data from OnePoint to SystemCenterReporting DB

1.1 Scheduled Task: SystemCenterDTSPackageTask
Schedule: 1am everyday

Check the task if successfully by looking at the field LastResult in Control Panel->Scheduled Tasks.

0x0 - successed
0xffff - failed

When failed, you can check Application Log in Control Panel->Administration Tools->Event Viewer.

If it failed with Expired Timeout, try to increase query timeout in MOM SQL Server to aovid this error.

1.2 Check the last completely run of DTS job in OnePoint database

select TimeDTSLastRan from OnePoint.dbo.reportingsettings

1.3 Check DataRetentionDays in OnePoint DB and see how many days data requires to be moved.

select * from OnePoint.dbo.groomingsettings

1.4 May need to add /latency to DTS job to speed up the large data moving if it has been failed a few days.

ex: DataRetentionDays =3 and TimeDTSLastRan= 3 days ago,
could set /latency:3

C:\Program Files\Microsoft System Center Reporting\Reporting\MOM.Datawarehousing.DTSPackageGenerator.exe" /silent /latency:3 /srcserver:mom_server_name /srcdb:OnePoint /dwserver:mom_dw_server_name /dwdb:SystemCenterReporting /product:"Microsoft Operations Manager

2. Purge the transferred data in OnePoint DB.

Run SQL Job "MOMX Partitioning And Grooming" to purge the transferred data in OnePoint DB.


3. Run SCDWGroomJob to purge Reporting DB.

3.1 Check Reporting Grooming Day

USE SystemCenterReporting
GO

SELECT CS.TableName AS TableName, WCS.GroomDays AS GroomDays
FROM SMC_Meta_WarehouseClassSchema WCS
JOIN SMC_Meta_ClassSchemas CS
ON CS.ClassID = WCS.ClassID
WHERE WCS.MustBeGroomed = 1
ORDER BY WCS.GroomDays DESC


3.2. Set Reporting Grooming day
--------------------------------------------
USE SystemCenterReporting
GO
Declare @Groomdays int
-- Retain data for 145 days
Select @Groomdays = 145
exec p_updateGroomDays 'SC_AlertFact_Table', @Groomdays
exec p_updateGroomDays 'SC_AlertHistoryFact_Table', @Groomdays
exec p_updateGroomDays 'SC_AlertToEventFact_Table', @Groomdays
exec p_updateGroomDays 'SC_EventFact_Table', @Groomdays
exec p_updateGroomDays 'SC_EventParameterFact_Table', @Groomdays
exec p_updateGroomDays 'SC_SampledNumericDataFact_Table', @Groomdays

3.3 Start the reporting grooming job (called SCDWGroomJob) in the SQL Agent jobs.

Or run the actual stored procedure:

EXECUTE dbo.p_GroomDatawarehouseTables

If reporting grooming job has been failed for a while, you may have to set Grooming Day to trim the data gradually out of the reporting database.

Usually this job is time-consuming, watch it out after resetting the grooming day in case of the job failure.

Mar 5, 2008

unexpected log grow in Simple Recovery Mode

Log file was growing unexpectedly in Simple Recovery Mode during huge data purging process.
It was strange. My SQL Server is 2000 SP4.

Solution:
1. Check Trans Log file
The log was keeping growing.

2. Check Active Transaction
USE
[yourDB]
GO
DBCC OPENTRAN
GO

3.
Manually reset DB to Simple Recovery Mode
SP_DBOPTION [yourDB]
SP_DBOPTION [yourDB], 'trunc. log on chkpt.', 'true'
SP_DBOPTION [yourDB]

4. Shrink Trans log to the target size.
USE [yourDB]
GO
DBCC SHRINKFILE ('yourDBLog' , TargetSize)
GO

5. Monitor Trans Log growth.
Inactive transaction log entries should be cleared out at every checkpoint.

Should leave the log to a certain size, does NOT make sense to shrink it again unless an unusual over-volume transactions happen.

Mar 4, 2008

Harden Oracle and SQL Server - excelleent documents

http://www.cisecurity.org/

http://csrc.nist.gov/checklists/repository/category.html

Fix: "Difference of two datetime columns caused overflow at runtime" in Performance Dashboard.

Error: Difference of two datetime columns caused overflow at runtime
Solution: to modify msdb.MS_PerfDashboard.usp_Main_GetSessionInfo

sum(convert(bigint, datediff(ms, login_time, getdate()))) - sum(convert(bigint, s.total_elapsed_time)) as idle_connection_time,

to:

sum(convert(bigint, CAST ( DATEDIFF ( minute, login_time, getdate()) AS BIGINT)*60000 + DATEDIFF ( millisecond, DATEADD ( minute, DATEDIFF ( minute, login_time, getdate() ), login_time ),getdate() ))) - sum(convert(bigint, s.total_elapsed_time)) as idle_connection_time,

Oct 23, 2007

Fix login and user issues after moving SQL Server database

Unbelievably, this happens all the time after I restored the databases on the different server,
even I used the suggestion from http://support.microsoft.com/kb/246133.

I think I'd better put somewhere for the late on usage. Here it is.

1. Check the properties of login sa.
If find your database is not mapped to sa, run the following command in Query Window.

use [your DB Name]
go
exec sp_changedbowner 'sa'

go

2. Check other users under your database.
Run the following command, you'll see the users need to be fix.

use [your DB Name]
go

exec sp_change_users_login 'Report'

go

3. Fix users listed above.

use [your DB Name]
go

exec sp_change_users_login 'Auto_Fix','yourDBUser'
go

Oct 12, 2007

Oracle bids $6.66B for BEA Systems

 
Oracle is opening its mouth again.
 
Check this Oracle bids $6.66B for BEA Systems  in Star web site.
 
Who is going to be the next?

Aug 3, 2007

Identify your SQL Server version and SP

--
--For SQL 6.5 or later
--
select @@version
go
sp_server_info
go

--
--For SQL 2000 or later
--
SELECT SERVERPROPERTY('productversion'), SERVERPROPERTY ('productlevel'), SERVERPROPERTY ('edition')
go

Aug 2, 2007

EXP-00056: ORACLE error 904 encountered

Oracle Version: 9.2.0.8.0

Error Messsage when tried to export a schema:

EXP-00056: ORACLE error 904 encountered
ORA-00904: "SYS"."DBMS_EXPORT_EXTENSION"."FUNC_INDEX_DEFAULT": invalid identifier

Explanation from Metalink Note:358508.1:

After the patchset installation, the data dictionary components have not been upgraded to the patchset release (e.g. 10.1.0.4).

A patchset (e.g. 10.1.0.4) was applied to an existing ORACLE_HOME install but one or more of thepatchset steps were not performed per the patchset readme to bring the database components up to the same version as the patched software as shown in DBA_REGISTRY.


If the database components versions do not match the software and the running instance then the exp utility fails as it finds an earlier version of the exp packages in the database.

Check:
From the following I can see three components are still have the old version.

select COMP_ID,COMP_NAME,VERSION,STATUS,SCHEMA,PROCEDURE from DBA_REGISTRY
COMP_ID COMP_NAME VERSION STATUS SCHEMA PROCEDURE

-------- ------------------------------ ---------- ----------- -------- -----------------------------------
CATALOG Oracle9i Catalog Views 9.2.0.6.0 VALID SYS DBMS_REGISTRY_SYS.VALIDATE_CATALOG

CATPROC Oracle9i Packages and Types 9.2.0.6.0 VALID SYS DBMS_REGISTRY_SYS.VALIDATE_CATPROC

OWM Oracle Workspace Manager 9.2.0.1.0 VALID WMSYS OWM_VALIDATE

3 rows selected.

Suggested Solution:
Connect with SYS user with SYSDBA privileges
SQL> STARTUP MIGRATE
SQL> SPOOL patch.log
SQL> @?/rdbms/admin/catpatch.sql
SQL> SPOOL OFF
SQL> SHUTDOWN
SQL> STARTUP

Jul 5, 2007

10g Recycle Bin

Oracle 10g Recycle Bin is a virtual container to hold dropped objects until owner or DBA purges them out or when no more free space left in its tablespace which needs to save more data or a new object.

Default recyclebin is ON. After a table or index is dropped, you will see a new table or index with a long name like BIN$% under current schema. As some systems created and dropped tables very often "by design", in 10g this may bother some users to see many BIN$% tables which are not able to be dropped by using "drop table" command".

The following are something need to know about it:


1. Check recycle bin

SQL> show recyclebin;
SQL> select * from recyclebin;
SQL> select * from user_recyclebin;
SQL> select * from dba_recyclebin; --with DBA privilege

ORIGINAL NAME RECYCLEBIN NAME OBJECT TYPE DROP TIME
---------------- ------------------------------ ------------ -------------------
SEQ_TELE BIN$NEZqOOkqZdrgRAADung28g==$0 TABLE 2007-07-02:06:37:26
TORCMPLIST BIN$NH0oo3EvagvgRAADung28g==$0 TABLE 2007-07-04:23:56:05
TORCMPLIST BIN$NGnVEBsMIJ/gRAADung28g==$0 TABLE 2007-07-04:00:52:42
TORCMPLIST BIN$NFlS+mOZHurgRAADung28g==$0 TABLE 2007-07-03:05:11:00


you can see multiple versions of dropped table. Cool!

2. Check the content in a dropped table.

Dropped objects still occupy the space in the database until manually purged or automatically removed by the database itself.

SQL> select * from "BIN$NFlS+mOZHurgRAADung28g==$0"


3. Flashback dropped table from recycle bin

This gives you a chance to bring back the dropped table.

SQL> FLASHBACK TABLE
SEQ_TELE TO BEFORE DROP RENAME TO SEQ_TELE_old;

--Flashback dropped table when it has mltiple versions
SQL> FLASHBACK TABLE "BIN$NFlS+mOZHurgRAADung28g==$0" TO BEFORE DROP RENAME TO TORCMPLIST_20070703051100;

4. Purge recycle bin

In order to avoid losing data by accident, by checking drop time of dropped objects, they can permanently and safely be removed from the database.
SQL> PURGE TABLE tablename;                   -- Remove specific table from recycle bin.
SQL> PURGE INDEX indexname; -- Remove specific index from recycle bin.
SQL> PURGE TABLESPACE ts_name; -- Empty recycle bin for a specific tablespace under current user.
SQL> PURGE TABLESPACE ts_name USER username; -- Empty recycle bin for a specific user under a specific tablespace.
SQL> PURGE RECYCLEBIN; -- Empty recycle bin for current user.
SQL> PURGE DBA_RECYCLEBIN; -- Empty the entire recycle bin in the database by DBA
5. Disable recycle bin feature

It is NOT recommneded as you lose the chance to easily restore the accidentally dropped table back. Think about how difficultly to do this prior to 10g.

SQL> alter seesion set recyclebin=off;
SQL> alter system set recyclebin=off;

Jul 4, 2007

[MySQL]Step by Step to Set up MySQL v4.x Replication

==
== Step by Step to Set up MySQL Replication on FC4
==
== MySQL Version: 4.1.11
== Fedora Core 4
==
== master: mysql1
== slave : mysql2
==
== It is a good practice, even with these old releases.
==
==============================================

== Configure Master Node
===============================================
--
--1. Update my.cnf
--
vi /etc/my.cnf

[mysqld]
log-bin ==> trun on binary log for replication
server-id=1 ==> unique against all slaves
binlog-do-db = mysql ==> database needs to generate binary log
binlog-do-db = test ==> reapet this for more databases

[mysqld_safe]
err-log=/var/log/mysqld.log ==> MySQL log file
pid-file=/var/run/mysqld/mysqld.pid ==> to save MySQL pid

--
--2. Restart master mysql
--
$ ps -efgrep mysqld
$ KILL -9 pid
$ /usr/bin/mysqld_safe --defaults-file=/etc/my.cnf --pid-file=/var/run/mysqld/mysqld.pid &

or
$ /etc/init.d/mysqld restart

--check if the log file is generated under datadir directory
$ ls -ltr datadir
or
mysql> show master logs;

--
--3. Create replcation account, which is used to access master from slave.
--
mysql> GRANT REPLICATION SLAVE ON *.* TO 'repl'@'mysql2.domain' IDENTIFIED BY 'password';

mysql> FLUSH PRIVILEGES;

mysql> select * from mysql.user where user='repl'\G;

--
--4. Verfiy access in slave node
--
$ mysql -u repl -p -h mysql1

--
--5. Take database snapshot on master node
--
-- Closes all open tables and locks all tables for all databases with a read lock.
mysql> FLUSH TABLES WITH READ LOCK;

mysql> show master status;
+-------------------+----------+-------------------+------------------+
File Position Binlog_Do_DB Binlog_Ignore_DB
+-------------------+----------+-------------------+------------------+
mysql1-bin.000010 79 mysql,test
+-------------------+----------+-------------------+------------------+
1 row in set (0.00 sec)

--
--tar database files for each database
--
$ cd datadir/mysql
$ tar -cvf /tmp/mysql-snapshot.tar .
$ cd datadir/test
$ tar -cvf /tmp/test-snapshot.tar .

--re-enable write activities
mysql> UNLOCK TABLES;
Query OK, 0 rows affected (0.00 sec)


===========================================
== Configure Slave - mysql2
===========================================
--
--1. restore BACKUP SNAPSHOT to datadir
--
$ cd datadir/mysql
$ tar -xvf mysql-snapshot.tar
$ cd datadir/test
$ tar -xvf test-snapshot.tar

--
--2. Verfiy master database access from slave node
-- make sure access is successful before continuing
$ mysql -u repl -p -h mysql1

--Check mysql log if failed
$ tail -f /var/log/mysqld.log

--
--3. Configure my.cnf for replication
--
vi /etc/my.cnf

[mysqld]
server-id=2 ==> unique among master and slaves
replicate-do-db = mysql ==> database needs to be replicated
replicate-do-db = test ==>

[mysqld_safe]
err-log=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

Note:
without setting replicate-do-db, I got the following error:
070703 15:26:29 [ERROR] Slave I/O thread: error connecting to master 'repl@mysql1:3306': Error: 'Can't connect to MySQL server on 'mysql1' (13)' errno: 2003 retry-time: 60 retries: 86400

--

--4. Start slave mysql
--
/usr/bin/mysqld_safe --defaults-file=/etc/my.cnf --pid-file=/var/run/mysqld/mysqld.pid &
or
$ /etc/init.d/mysqld start

--
--5. Set up master info for replication
--
$ mysql -u root -p mysql

--set master
--log file and position from above result of "show master status;"
--
CHANGE MASTER TO
MASTER_HOST='mysql1',
MASTER_USER='repl',
MASTER_PASSWORD='password',
MASTER_PORT=3306,
MASTER_LOG_FILE='mysql1-bin.000010',
MASTER_LOG_POS=79;

--
--6. start slave I/O and SQL Thread
-- stop slave
mysql> START SLAVE;

--
--7. Verify slave is running
--
mysql> show slave status\G;
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: mysql1
Master_User: repl
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql1-bin.000013 ==> read by I/O Thread
Read_Master_Log_Pos: 139
Relay_Log_File: mysql2-relay-bin.000001 ==> read by SQL Thread
Relay_Log_Pos: 1054
Relay_Master_Log_File: mysql1-bin.000013
Slave_IO_Running: Yes ==> make sure I/O thread is running
Slave_SQL_Running: Yes ==> make sure SQL thread is running
Replicate_Do_DB: mysql,test ==> replicated databases
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 0
Last_Error:
Skip_Counter: 0
Exec_Master_Log_Pos: 139
Relay_Log_Space: 1054
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: 0
1 row in set (0.00 sec)

ERROR:
No query specified

--
--8. Check mysql log
--
$ tail -f /var/log/mysqld.log