Saturday, April 14, 2012

Dynamic SUBSTRING() in MS SQL

My requirement is to use the SUBSTRING() dynamically in SQL query.
I have the set of data in a table. I want to pick only the last 6 digits.


General syntax of the SUBSTRING function
SUBSTRING ( expression ,start , length )
I'm using below query according to my requirement.

SELECT SUBSTRING(VALUE,LEN(VALUE)-6+1,LEN(VALUE)+1) FROM TEST




How to get the MS SQL Server Version

Use the below Query
SELECT @@version

Sunday, April 8, 2012

Get Specify Date by using GETDATE() in MS SQL

My requirement is to get the 1st date of the year. I'm using below command line to fulfill this task.
SELECT CONVERT(VARCHAR,YEAR(GETDATE())-1)+'/01/01'  

When it become the last day of the year, I can change the query like this.
SELECT CONVERT(VARCHAR,YEAR(GETDATE())-1)+'/12/01' 


Then I want the 1st February in this year. It can be taken by using
SELECT CONVERT(VARCHAR,YEAR(GETDATE())-1)+'/02/01'  

I believe this command will help you to cater your various requirements. 

Table Backup in SQL

You can create table backups by using below commands.

In MS SQL
SELECT * INTO <backup_table_name> FROM <original_table_name>
Ex:
SELECT * INTO FUEL_DETAILS_BACK FROM FUEL_DETAILS 

In Oracle
CREATE TABLE   <backup_table_name>  AS SELECT * FROM <original_table_name>
Ex:
CREATE TABLE HR_LEAVE_ENTITLE2011 AS 
SELECT * FROM HR_LEAVE_ENTITLE

Sunday, April 1, 2012

Register the .Net Framework in Windows Server Editions

Open the Command Prompt and Run the below command.

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727>aspnet_regiis.exe -i






Saturday, March 24, 2012

Enable 32 bit in IIS Windows Server 2003 64 bit

Open the command prompt and run below command to enable 32 bits applications hosted  in IIS of Windows Server 2003 64 bit edition since the option is not available through the interface.

cscript %SYSTEMDRIVE%\inetpub\adminscripts\adsutil.vbs SET W3SVC/AppPools/Enable32bitAppOnWin64 1

Sunday, February 12, 2012

CONCATENATE() & SUBSTITUTE() in MS EXCEL

I'm using Microsoft Excel for formatted my data sheet. 
I want to merge few cells data to a one cell. The way of I do this
I want to remove some selected values in a cell. The way of I do this