Pages

Wednesday, February 15, 2012

Get data type of a table in database dynamically

You can get the data types of columns in a given table daynamically using system tables as given below: Assume 'CurrentStatus' is the table name.









The column name and the data type will be diplayed as result.

Tuesday, February 14, 2012

Monday, February 13, 2012

JOIN vs IN vs EXISTS in sql

Difference between IN and EXISTS
  • IN will ignore null values where as EXISTS will considers null values as the result.
  • JOIN also, will consider null values.
Difference between IN and JOIN
  • IN does not consider duplicate values where as JOIN consider duplicates. (To avoid duplicate values, use DISTINCT)
  • EXISTS also does not consider duplicate values.

Wednesday, February 8, 2012

Why/ Why not use "WITH RECOMPILE" option?

Once the sproc does not have any syntax errors, it will create entries in sysobjects, sysdepends and syscomments tables. But, it will not compile the query until you execute that.

At the time you execute the proc, SQL Server will create an execution plan and save that in procedure cache for future use.

When the proc executes again, it will re-use the same execution plan, unless otherwise statistics are being changed.

So, if you want to use a new execution plan for each individual execution, use WITH RECOMPILE option in your proc.

Why?
- Optimal use of indexes on columns in a case by case scenario

Why not?
- Improves performance

Add an alias to connect database server using SSMS in MSSQL

  1. All Programs > SQL Server Configuration Manager
  2. Expand SQL Native Client 10.0 Configuration
  3. Aliases
  4. New Alias



Wednesday, February 1, 2012

Linux Kernal Headers

Linux kernal headers provide APIs to interact between modules in kernal level as well as modules between user space and kernal space.

If you want to do any kernal level operations in Linux, you need to use above APIs with C language.

It is located at /usr/src/linux-headers-x.x. See below:



How to fix "The program 'gcc' can be found in following packages' issue

GCC is the compiler environment for Linux. Once you type "gcc" in cmd, you will get the following error if gcc is not installed.






To fix this issue, run following command:
sudo apt-get install build-essential

Create and Edit and Save a file in Linux

  1. pico test.c
  2. Type your content
  3. ctrl + x
  4. Select option 'Y'

Get process information in Linux

Use "top" command

How to get system information in Linux?

Use uname -m command to see whether your kernal is 64-bit or 32-bit. uname -ar will give you the other system and OS information such as machine name, Linux version etc.

get Linux system information