Wednesday, June 01, 2016

How to select data in a column with only INT?

Recently I ran into an issue where i need to filter column to get only integer values.

select * from employee where ISNUMERIC(employeeid ) = 1

ISNUMERIC function returns 1 if the expression is a valid number. Otherwise, it returns 0

The ISNUMERIC function can be used in the following versions of SQL Server (Transact-SQL):

  • SQL Server 2014, SQL Server 2012, SQL Server 2008 R2, SQL Server 2008, SQL Server 2005

Monday, May 23, 2016

Can't access internal storage from a computer after installing Marshmallow on Android device?

Recently I have update my OnePlus One phone to latest version of Android 6.0 (Marshmallow)

After I have updated to latest version I can’t access internal storage how I used to access before. Due to security options in 6.0 there are few options that were changed to enable access.

Here's how I could able to fix it.

  1. Open Settings
  2. Enable Developer options:
    1. Go to About phone (or tablet)
    2. Scroll to the bottom
    3. Tap Build number repeatedly. After several taps you will see it count down and then say "You are now a developer!"
  3. Back to Settings
  4. Tap Developer options, near the bottom
  5. Scroll down to and tap Select USB Configuration
  6. Change it to Charging only
  7. Tap Select USB Configuration again
  8. Change it back to MTP (Media Transfer Protocol)

That's it. You should now be able to open up the internal storage on the device from your computer.

Hope this helps!!

Monday, March 21, 2016

Compatibility mode in IE–Developer

Enable Compatibility mode in IE through code in .NET or Web.config or HTML meta tag.

We can achieve this by setting the value of the compatibility mode.

Web page can specify compatibility mode either by using META tag or by setting the HTTP header, note thatMETA tag will take precedence over http header when both are present.

Sol 1: META Tag- place the following code in head element of web page (HTML page).

<meta http-equiv="X-UA-Compatible" content="IE=8, IE=9"/> 

Sol 2: HTTP Header- We can configure our server to send a HTTP Header along with each page i.e., send X-UA-Compatibility: IE=8 HTTP header 

Add the following code snippet in web.config file:

<system.webServer>
    <httpProtocol>
        <customHeaders>
            <clear/>
            <add name="X-UA-Compatible" value="IE=9"/>
        </customHeaders>
    </httpProtocol>
<system.webServer>

Here are other options:

  • "IE=edge"
  • "IE=11"
  • "IE=EmulateIE11"
  • "IE=10"
  • "IE=EmulateIE10"
  • "IE=9"
  • "IE=EmulateIE9
  • "IE=8"
  • "IE=EmulateIE8"
  • "IE=7"
  • "IE=EmulateIE7"
  • "IE=5
 

Wednesday, January 20, 2016

How can I list all foreign keys referencing a given table in SQL Server?

Here is how you can get list of all foreign key references using below query for all tables in your database

SELECT obj.name AS FK_NAME,
sch.name AS [schema_name],
tab1.name AS [table],
col1.name AS [column],
tab2.name AS [referenced_table],
col2.name AS [referenced_column]
FROM sys.foreign_key_columns fkc
INNER JOIN sys.objects obj
ON obj.object_id = fkc.constraint_object_id
INNER JOIN sys.tables tab1
ON tab1.object_id = fkc.parent_object_id
INNER JOIN sys.schemas sch
ON tab1.schema_id = sch.schema_id
INNER JOIN sys.columns col1
ON col1.column_id = parent_column_id

AND col1.object_id = tab1.object_id
INNER JOIN sys.tables tab2
ON tab2.object_id = fkc.referenced_object_id
INNER JOIN sys.columns col2
ON col2.column_id = referenced_column_id

AND col2.object_id = tab2.object_id


Hope this helps!!!

Tuesday, January 12, 2016

Android Version History

The version history of the Android mobile operating system began with the release of the Android alpha in November 2007. The first commercial version, Android 1.0, was released in September 2008. Android is continually developed by Google and the Open Handset Alliance (OHA)

2016-05-23_1414

** Added for my own references