Thursday, August 30, 2012

Unable to Add Oracle Datasource in Windows 7 64bit

  • OS: Windows 7, 64bit.
  • Installed OracleXE 11g.
  • Trying to create a new data source under system DSN, by going through control panel and administrative tools.
  • However, Oracle drivers are not listed.
Solution:
The data source dialog is for 64 bit clients. In case Oracle client installed is 32 bit, then you open the 32 bit dialog using:

C:\Windows\SysWOW64\odbcad32.exe

 or under your respective windows folder

Thursday, May 31, 2012

Windows XP security tab missing on folder properties

On fresh install of xp in workgroup mode security tab was missing.

I tried various registry hacks as specified in different posts, but what worked is follows:
Solution from microsoft help:


To display the Security tab
  1. Open Folder Options in Control Panel.
    • Click Start, point to Settings, and then click Control Panel.
    • Double-click Folder Options
    • .
  2. On the View tab, under Advanced settings, clear Use simple file sharing [Recommended].

Wednesday, April 25, 2012

Dell Latitude Laptop D630 with NVIDIA Quadro NVS 135M Graphics Card.

Its summer time and temperature above 40degrees C. Laptop started freezing after running for a while, ranging from 10 minutes to 30 minutes. You could see that nothing else works, no keys nothing.

Thought might be some software problem. However, figured out its the problem with the graphics cards themselves. Unfortunate to have got this problem after 1 year of warranty expiration due to very low laptop usage.

Links that talk about this problem:
http://www.theinquirer.net/inquirer/news/1028703/all-nvidia-g84-g86s-bad

http://en.community.dell.com/dell-blogs/direct2dell/b/direct2dell/archive/2008/08/18/nvidia-gpu-update-dell-to-offer-warranty-enhancement-to-all-affected-customers-worldwide.aspx

http://en.community.dell.com/support-forums/laptop/f/3519/t/19286119.aspx

Dell should have been more proactive about providing this information to customers. I am going to try to contact them to get it fixed. However, if they don't help out, then there is no other alternative. But that shows that what these laptop vendors can do to customers.


Friday, September 9, 2011

How to add a check constraint on a table



Syntax:
ALTER TABLE
   ADD CONSTRAINT CHECK ()
Example:

It is always better to check for existence before adding any object to avoid any runtime errors:

IF NOT EXISTS (SELECT 1 FROM sys.objects WHERE name = 'CK_ProductReview_Rating' AND type = 'C')
ALTER TABLE Production.ProductReview
ADD CONSTRAINT CK_ProductReview_Rating CHECK (([Rating]>=(1) AND [Rating]<=(5)))

If you are adding a CHECK constraint on an existing table with data, and the conditions of the constraint are invalid, it would not be able to create the check constraint. However, the error it throws does not give a clear indication of the reason. It seems to indicate that a constraint already exists, so you need to check for the conditions:

Msg 547, Level 16, State 0, Line 2
The ALTER TABLE statement conflicted with the CHECK constraint "CK_ProductReview_Rating". The conflict occurred in database "AdventureWorks", table "Production.ProductReview", column 'Rating'.

How to drop a check constraint


Syntax:
ALTER TABLE DROP CONSTRAINT ;
Example:
-- Drop a check constraint
IF EXISTS (SELECT 1 FROM sys.objects WHERE NAME = 'CK_ProductReview_Rating' AND type = 'C')
ALTER TABLE Production.ProductReview DROP CONSTRAINT CK_ProductReview_Rating;

How to get the Table Name on which the Check Constraint is defined


You can use the following code block to get the information for a given check constraint

DECLARE @ConstraintName varchar(130)
SET @ConstraintName = 'CK_ProductReview_Rating'

SELECT  t.name as TableName,
            c.name as CheckConstraintName,
            c.definition as ConstraintDefinition
FROM  sys.objects t,
            sys.check_constraints c
WHERE c.parent_object_id = t.object_id
AND         c.name = @ConstraintName

Query Error when using ORDER BY if the column and * is in the SELECT list


Suppose, you have a query where you get one column explicitly and all other columns using * then you get an Ambiguous column name error.
The following query results in an error:
SELECT Title,* FROM HumanResources.Employee ORDER BY Title

Msg 209, Level 16, State 1, Line 1
Ambiguous column name 'Title'.

The following does not give an error:
SELECT Title,* FROM HumanResources.Employee

So whats’s the solution?
Adding an alias for the table and using alias with the column in ORDER BY or providing a fully qualified path to the column in ORDER BY will fix this issue.

One of the following query will fix this issue.
SELECT Title,* FROM HumanResources.Employee e ORDER BY e.Title
SELECT Title,* FROM HumanResources.Employee ORDER BY HumanResources.Employee.Title

If the Title column was not in SELECT list, the issue would not arise. The following query works perfectly:
SELECT * FROM HumanResources.Employee ORDER BY Title

Also, if you didn’t have * in your select, but just specific list of columns, then also you do not need to have alias in order by
SELECT EmployeeID,Title FROM HumanResources.Employee ORDER BY Title

So, it’s only when you have a combination of explicit column name and a * in the SELECT you get this issue.

Weird issue or the way syntax is expected by SQL. However, you have to live by some quirks which creates jobs for DB programmers.