Monday, February 16, 2015

SELECT INTO Query in SQL Server.

In SQL Server we can create a Table using another Table.

Here we can use SELECT INTO Statement.

If we create a new Table with all the Fields and Data of another Table. Then we use...

SELECT * INTO <new_table>
FROM <existing_table>

Or we can use WHERE Clause...

SELECT * INTO <new_table>
FROM <existing_table>
WHERE 1 = 1

Now if we create the Table only the Fields of another Table. Then we use...

SELECT * INTO <new_table>
FROM <existing_table>
WHERE 1 = 0

Wednesday, February 11, 2015

XML Path in SQL Server

XML PATH AND STUFF FOR for String Concatenation in SQL Server

We can use XmlPath('') to concatenate column data into single row.
Stuff is used to remove the first ‘,’ after string concatenation.

STEP 1:- Create a Table named ‘CITY’

CREATE TABLE CITY (CT_ID Int, CT_Name Varchar(20))

STEP 2:- Insert Data in ‘CITY’ Table

INSERT INTO CITY
SELECT 1,'KOLKATA' UNION ALL SELECT 1,'TARAKESWAR' UNION ALL
SELECT 2,'MUMBAI' UNION ALL SELECT 3,'DELHI' UNION ALL
SELECT 4,'CHENNAI' UNION ALL SELECT 5,'BENGALURU' UNION ALL
SELECT 6,'GOA' UNION ALL SELECT 2,'PUNJAB' UNION ALL
SELECT 3,'SHIMLA' UNION ALL SELECT 4,'CHANDIGARH' UNION ALL
SELECT 5,'AHMEDABAD' UNION ALL SELECT 6,'IMPHAL' UNION ALL
SELECT 1,'DUMDUM' UNION ALL SELECT 2,'JAIPUR' UNION ALL
SELECT 3,'VIZAG' UNION ALL SELECT 4,'HYDERABAD' UNION ALL
SELECT 5,'RAIPUR' UNION ALL SELECT 6,'GUWAHATI'

STEP 3:- SELECT * FROM CITY



STEP 4:- Now we use STUFF() and XML Path('') Function in SQL Query.

SELECT DISTINCT CT_ID,
STUFF(( SELECT ',' + CT_NAME
            FROM CITY T1
            WHERE T1.CT_ID = T2.CT_ID
       FOR XML PATH('')),1,1,'')
            FROM CITY T2





















Thank You! J

Tuesday, February 10, 2015

Indian Travelers Can Travel 56 Countries Without Visa!

Bhutan
Bolivia – 90 days
Burundi – 30 days; obtainable at Bujumbura International Airport
British Virgin Islands

Cambodia – 30 days
Cape Verde
Comoros
Cook Islands – 31 days

Djibouti
Dominica – 6 months

Ecuador – 90 days
Ethiopia
El Salvador – 90 days

Fiji – 4 months

Guinea-Bissau – 90 days
Guyana – 30 days provided holding confirmation, issued by the Ministry of Home Affairs
Grenada – 3 months

Haiti – 3 months
Hong Kong – 14 days

Indonesia – 30 days

Jamaica
Jordan – 2 weeks, must hold US$ 3000

Kenya – 3 months
Kish Island – No visa is required for visitors to Kish Island.

Laos – 30 days

Macau – 30 days
Madagascar – 90 days
Maldives – 90 days
Mauritius- 90 days
Micronesia – 30 days
Montserrat – 6 months

Nauru
Nepal – Freedom of movement based on the terms of the 1950 Indo-Nepal Treaty of Peace and Friendship that allows Indian citizens to live and work freely in Nepal.
Niue – 30 days

Palau – 30 days
Palestine – Arrival by sea to Gaza Strip not allowed
Pitcairn Islands – 14 days visa free and landing fee 35 USD or tax of 5 USD if you are not going ashore is required.

Saint Lucia – 6 weeks
Samoa – 60 days
Saint Kitts and Nevis – 3 months
Saint Vincent and the Grenadines – 1 month
Seychelles – 1 month
Somalia – 30 days, provided an invitation letter issued by the sponsor has been submitted to the    Airport Immigration Department at least 2 days before arrival.
Somaliland – 30 days for 30 US dollars, payable on arrival
Svalbard – Visa is not required for entry to Svalbard but practically it’s impossible to board a flight/ferry to Svalbard without going through Norway therefore, this would invariably require a double entry Schengen visa in order to go and come back from Svalbard to mainland Norway.

Tanzania
Thailand – 15 days. Visa fee of 1000 Thai Baht needs to be paid in Thai currency. Visa on Arrival has to be obtained at First point of entry/Landing not the Final Destination.
Timor-Leste – 30 days
Turkish Republic of Northern Cyprus – 3 months
Transnistria – Registration required after 24h
Trinidad and Tobago – 90 days
Togo – 7 days
Tuvalu – 1 month
Turks and Caicos Islands – 30 days

Uganda

Vanuatu – 30 days