Tuesday, 25 May 2010

ASP .Net: Greybox close and refresh parent

There are several steps to this process.

1. Create function in Master page to create new window reload


<script type="text/javascript">

        GB_myShow = function(caption, url, height, width, is_reload_on_close) {

            var options = {

                caption: caption,

                height: height || 500,

                width: width || 500,

                fullscreen: false,

                overlay_click_close: true,

                show_loading: true,

                reload_on_close: is_reload_on_close || false,

                center_win: true

            }

            

        win = new GB_Window(options);

        

            return win.show(url);

        }

    </script>




2. Call class


<a href="Help/PreviousFilter.aspx" onclick="return GB_myShow('Previous Filters', this.href, 330,500, true)" style="color:Blue;"><img src="graphics/Search.png" height="16px" title="Previous Filters" alt="#" /></a>



3. Close parent window
parent.parent.GB_hide();


parent.parent.GB_hide();

<div class="viewcode">

   string test = Session["FilterValue"].ToString();

            string strscrip

Publish Post

t = "<script language=javascript> parent.parent.GB_hide(); </script>";

            //if (window.opener && !window.opener.closed) { window.opener.location.reload(); } </script>";

            //window.top.close();

            if (!ClientScript.IsStartupScriptRegistered("clientScript"))

                ClientScript.RegisterStartupScript(Page.GetType(), "clientScript", strscript);

</div>




Friday, 21 May 2010

SQL: Alter schema of table

To alter schema:

Alter Schema NewSchema Transfer dbo.tablename

Friday, 5 March 2010

Website: Get noticed in google search engine

Check out: http://www.vodahost.com/vodatalk/google/11694-google-search-does-not-show-my-page.html


Step 1: check can be viewed in googlebot by using Lynx viewer
http://www.yellowpipe.com/yis/tools/lynx/lynx_viewer.php

Step 2: look at google's webmaster guidelines:
http://www.google.com/support/webmasters/bin/answer.py?answer=35769

Step 3: Give your page title something like "Microsoft Business Intelligence Consultant John Ilett"
Right-click on your BV page (away from any element or object), and you will see Page Properties > Click > Page Properties Dialog Box...

Step 4: General tips
It needn't be so, however, and at VodaHost, we believe you will find no easier means to apply this technical expertise to your website designs as an effective element to your online success with the tools, technologies, and peer support so freely available!You need to "search" the various Forums here in VodaTalk to read up on various means to "optimize" you design to be 'friendly' to the Search Engines, as there are foundational methods and forms you need to consider.You can start in the "Search Engine Topics & VodaHits" Forum, and move to others like "General Support" where you can actually perform a "Search Forum" based on key words to bring up relevant topics as you glean information. (To "Search Forum" you will find this available in the blue header of the VodaHost "VodaTalk Forum" itself)Also, don't neglect the "KeyWord Digger" Tutorial already prepared for your use by VodaHost, which can visually tie together some of the new terms and principles for you whilst offering specific instructions on how to complete the task itself!To begin, actually right-click on a blank area of your page in Blue Voda, and then select PAGE PROPERTIES....tabbed, you will now see some of the various information you should carefully construct that is extremely important to how your Page is actually "recognized" and "cached" by the no-nonsense Search Engines....now you can understand the relevance of the mentioned principles, and have the means to investigate and learn them yourself!**When you have neared completion of your website, you should consider enrolling in the extremely affordable and very effective VodaHits SEO program. There is no better value for this critical service on the web!


More...
Search 1: andysbodyseBay Member Profile for andysbodysMember Profile : andysbodys ( 519 ) ... 627 feedback received by andysbodys ( 0 ratings mutually withdrawn ), Page 1 of 26 ...feedback.ebay.com/ws/eBayISAPI.dll?ViewFeedback&userid=andysbodys - 79k - Supplemental Result - Cached - Similar pagesSearch 2: andysbodiesDid you mean: andy's bodies Andy's Auto Sport - Body Kits and Carbon Fiber Hoods Superstore!You really need to see you are putting a space where it should never go.You have saved your pages as : http://andysbodies.net/You left out the www. part, first of all.....AND1. Your CONTACT US link lists the link "andys bodys.net/contact" See the space?? Use an underscore, if you need to between page titles, but you do NOT have a space in your registered domain, do you? > Nor should you anywhere else!2. You have not named/titled your pages, so there is no association for them to "Go" or even be "Found"

Wednesday, 3 March 2010

SQL: Performance tuning guide

http://www.sql-server-performance.com/tips/all_main.aspx

1. Query optimisation can be achieved using the Query optimiser on most common queries. Will determine best indexes to build.

INDEXES
2. ALL table should have a CLUSTERED INDEX - this is an index on PK which is increasining (only 1 per table).
3. Index should be considered on any column in WHERE, ORDER BY, GROUP BY, TOP and DISTINCT experssions. (may be optmial for one query but not for other).
4. Setting different settings on index can affect performance. Clustered, non clustered, and composite indexes as well as setting FILLFACTOR and PAD_INDEX.
5. Static tables (dont change frequently) set FILL and Pad_index to 100 and can be heavily indexed as update/insert/delete not a problem.
6. Drop indexes not used by the Query optimiser.

INDEXED VIEWS
1. Create indexed view. Must set up the following:
SET ANSI_NULLS ON
SET ANSI_PADDING ON
SET ANSI_WARNINGS ON
SET CONCAT_NULL_YIELDS_NULL ON
SET NUMERIC_ROUNDABORT OFF
SET QUOTED_IDENTIFIER ON
SET ARITHABORT ON
2.
CREATE VIEW Vdiscount1 WITH SCHEMABINDING AS
SELECT SUM(UnitPrice*OrderQty) AS SumPrice, SUM(UnitPrice*OrderQty*(1.00-UnitPriceDiscount)) AS SumDiscountPrice, COUNT_BIG(*) AS Count, ProductIDFROM Sales.SalesOrderDetail GROUP BY ProductID
GO
CREATE UNIQUE CLUSTERED INDEX VDiscountInd ON Vdiscount1 (ProductID,colb,..)

3. When to use indexed view:
Data marts, data warehouses, decision support, data mining, OLAP applications.
Views that join two or more large tables.
Views that aggregate data.
Repeated patterns of queries.

Triggers
1. 2 triggers(Instead and After).
If likely only a few rolebacks then use instead otherwise after as overhead is less.
2. When ordering first trigger set it to the most likely rollback trigger so doesn't have to rollback all triggers throughout.
3. Run Query anaylizer to see performance of trigger on system.

Check Constraint
1. Faster than trigger for referential integrity

Use SP for client calls
1. As SP reduce network traffic because SQL in SP and not over network.
2. More secure
3. Better logic.

**Turn off nocount
1. Everytime SP is run returns rowcount to client. This is rarely useful
2. Switch off either putting this is each sp:
SET NOCOUNT ON
or switch off:
SP_CONFIGURE 'user options', 512RECONFIGURE

Check running latest version:
SELECT @@Version

Database tuning Advisor
1. Run profiler to pick up all current queries. (SQL:BatchCompleted and the RPC:Completed)
2. Then save trace and point DB tuning advisor to it.

SSRS 2008: Column Header remain visible

Need to create a second group on dynamic group the same.
1. Then go to Report > Grouping.
2. In the groups (bottom of report) select the arrow in the top right hand corner and select advanced mode.
3. Click the top group and go to properties.
4. Set the FixedData to true.
5. Set Row Visibility of group below to hiden.

You're done!

Thursday, 25 February 2010

Publish code on site

http://newbloggingtipz.blogspot.com/2009/08/how-to-add-html-codes-in-blogger-posts.html

Step 1: Add this


<div class="codeview"> </div>




Step 2: Get code and convert using simple code.
http://www.simplebits.com/cgi-bin/simplecode.pl


Step 3: Publish

Thursday, 7 January 2010

SQL: Add Country table and insert Countries

--STEP 1: Create Country table
CREATE TABLE [dbo].[tbl_Countries](
[Country_id] [int] IDENTITY(1,1) NOT NULL,
[Country_name] [nvarchar](100) NULL,
[Country_ShortName] [nvarchar](20) NULL,
[Sort_order] [int] NULL,
[Active] [bit] NULL,
CONSTRAINT [PK_tbl_country] PRIMARY KEY CLUSTERED
(
[Country_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[tbl_Countries] ADD CONSTRAINT [DF_tbl_country_Active] DEFAULT ((1)) FOR [Active]
GO
--STEP 2: SET IDENTITY INSERT ON
SET IDENTITY_INSERT dbo.tbl_countries ON
--STEP 3: Insert all Countries (ID and Name)
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (2, 'Afghanistan');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (3, 'Albania');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (4, 'Algeria');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (5, 'American Samoa');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (6, 'Andorra');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (7, 'Angola');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (8, 'Anguilla');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (9, 'Antarctica');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (10, 'Antigua and Barbuda');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (11, 'Argentina');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (12, 'Armenia');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (13, 'Aruba');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (14, 'Australia');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (15, 'Austria');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (16, 'Azerbaijan');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (17, 'Bahamas');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (18, 'Bahrain');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (19, 'Bangladesh');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (20, 'Barbados');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (21, 'Belarus');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (22, 'Belgium');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (23, 'Belize');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (24, 'Benin');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (25, 'Bermuda');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (26, 'Bhutan');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (27, 'Bolivia');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (28, 'Bosnia and Herzegovina');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (29, 'Botswana');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (30, 'Bouvet Island');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (31, 'Brazil');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (32, 'British Indian Ocean territory');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (33, 'Brunei Darussalam');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (34, 'Bulgaria');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (35, 'Burkina Faso');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (36, 'Burundi');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (37, 'Cambodia');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (38, 'Cameroon');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (39, 'Canada');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (40, 'Cape Verde');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (41, 'Cayman Islands');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (42, 'Central African Republic');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (43, 'Chad');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (44, 'Chile');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (45, 'China');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (46, 'Christmas Island');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (47, 'Cocos (Keeling) Islands');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (48, 'Colombia');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (49, 'Comoros');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (50, 'Congo');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (51, 'Congo');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (52, ' Democratic Republic');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (53, 'Cook Islands');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (54, 'Costa Rica');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (55, 'Côte dIvoire (Ivory Coast)');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (56, 'Croatia (Hrvatska)');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (57, 'Cuba');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (58, 'Cyprus');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (59, 'Czech Republic');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (60, 'Denmark');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (61, 'Djibouti');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (62, 'Dominica');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (63, 'Dominican Republic');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (64, 'East Timor');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (65, 'Ecuador');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (66, 'Egypt');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (67, 'El Salvador');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (68, 'Equatorial Guinea');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (69, 'Eritrea');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (70, 'Estonia');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (71, 'Ethiopia');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (72, 'Falkland Islands');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (73, 'Faroe Islands');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (74, 'Fiji');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (75, 'Finland');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (76, 'France');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (77, 'French Guiana');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (78, 'French Polynesia');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (79, 'French Southern Territories');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (80, 'Gabon');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (81, 'Gambia');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (82, 'Georgia');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (83, 'Germany');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (84, 'Ghana');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (85, 'Gibraltar');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (86, 'Greece');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (87, 'Greenland');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (88, 'Grenada');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (89, 'Guadeloupe');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (90, 'Guam');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (91, 'Guatemala');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (92, 'Guinea');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (93, 'Guinea-Bissau');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (94, 'Guyana');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (95, 'Haiti');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (96, 'Heard and McDonald Islands');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (97, 'Honduras');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (98, 'Hong Kong');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (99, 'Hungary');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (100, 'Iceland');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (101, 'India');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (102, 'Indonesia');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (103, 'Iran');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (104, 'Iraq');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (105, 'Ireland');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (106, 'Israel');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (107, 'Italy');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (108, 'Jamaica');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (109, 'Japan');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (110, 'Jordan');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (111, 'Kazakhstan');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (112, 'Kenya');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (113, 'Kiribati');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (114, 'Korea (north)');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (115, 'Korea (south)');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (116, 'Kuwait');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (117, 'Kyrgyzstan');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (118, 'Lao Peoples Democratic Republic');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (119, 'Latvia');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (120, 'Lebanon');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (121, 'Lesotho');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (122, 'Liberia');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (123, 'Libyan Arab Jamahiriya');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (124, 'Liechtenstein');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (125, 'Lithuania');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (126, 'Luxembourg');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (127, 'Macao');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (128, 'Macedonia');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (129, 'Madagascar');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (130, 'Malawi');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (131, 'Malaysia');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (132, 'Maldives');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (133, 'Mali');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (134, 'Malta');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (135, 'Marshall Islands');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (136, 'Martinique');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (137, 'Mauritania');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (138, 'Mauritius');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (139, 'Mayotte');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (140, 'Mexico');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (141, 'Micronesia');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (142, 'Moldova');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (143, 'Monaco');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (144, 'Mongolia');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (145, 'Montserrat');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (146, 'Morocco');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (147, 'Mozambique');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (148, 'Myanmar');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (149, 'Namibia');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (150, 'Nauru');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (151, 'Nepal');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (152, 'Netherlands');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (153, 'Netherlands Antilles');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (154, 'New Caledonia');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (155, 'New Zealand');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (156, 'Nicaragua');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (157, 'Niger');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (158, 'Nigeria');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (159, 'Niue');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (160, 'Norfolk Island');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (161, 'Northern Mariana Islands');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (162, 'Norway');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (163, 'Oman');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (164, 'Pakistan');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (165, 'Palau');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (166, 'Palestinian Territories');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (167, 'Panama');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (168, 'Papua New Guinea');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (169, 'Paraguay');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (170, 'Peru');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (171, 'Philippines');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (172, 'Pitcairn');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (173, 'Poland');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (174, 'Portugal');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (175, 'Puerto Rico');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (176, 'Qatar');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (177, 'Réunion');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (178, 'Romania');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (179, 'Russian Federation');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (180, 'Rwanda');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (181, 'Saint Helena');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (182, 'Saint Kitts and Nevis');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (183, 'Saint Lucia');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (184, 'Saint Pierre and Miquelon');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (185, 'Saint Vincent and the Grenadines');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (186, 'Samoa');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (187, 'San Marino');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (188, 'Sao Tome and Principe');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (189, 'Saudi Arabia');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (190, 'Senegal');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (191, 'Serbia and Montenegro');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (192, 'Seychelles');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (193, 'Sierra Leone');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (194, 'Singapore');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (195, 'Slovakia');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (196, 'Slovenia');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (197, 'Solomon Islands');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (198, 'Somalia');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (199, 'South Africa');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (200, 'South Georgia and the South Sandwich Islands');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (201, 'Spain');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (202, 'Sri Lanka');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (203, 'Sudan');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (204, 'Suriname');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (205, 'Svalbard and Jan Mayen Islands');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (206, 'Swaziland');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (207, 'Sweden');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (208, 'Switzerland');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (209, 'Syria');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (210, 'Taiwan');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (211, 'Tajikistan');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (212, 'Tanzania');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (213, 'Thailand');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (214, 'Togo');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (215, 'Tokelau');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (216, 'Tonga');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (217, 'Trinidad and Tobago');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (218, 'Tunisia');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (219, 'Turkey');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (220, 'Turkmenistan');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (221, 'Turks and Caicos Islands');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (222, 'Tuvalu');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (223, 'Uganda');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (224, 'Ukraine');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (225, 'United Arab Emirates');
INSERT INTO dbo.tbl_countries (Country_id,Country_name,Sort_order) VALUES (226, 'United Kingdom',2);
INSERT INTO dbo.tbl_countries (Country_id,Country_name,Sort_order) VALUES (227, 'United States of America',1);
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (228, 'Uruguay');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (229, 'Uzbekistan');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (230, 'Vanuatu');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (231, 'Vatican City');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (232, 'Venezuela');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (233, 'Vietnam');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (234, 'Virgin Islands (British)');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (235, 'Virgin Islands (US)');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (236, 'Wallis and Futuna Islands');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (237, 'Western Sahara');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (238, 'Yemen');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (239, 'Zaire');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (240, 'Zambia');
INSERT INTO dbo.tbl_countries (Country_id,Country_name) VALUES (241, 'Zimbabwe');
--STEP 4: SET IDENTITY INSERT OFF
SET IDENTITY_INSERT dbo.tbl_countries OFF
GO
--STEP 5: CREATE VIEW
CREATE VIEW dbo.vwCountries AS
SELECT
[Country_id]
,[Country_name]
,[Country_ShortName]
,[Sort_order]
,[Active]
FROM [dbo].[tbl_Countries]
--STEP 6: SELECT FROM VIEW
GO
SELECT
[Country_id]
,[Country_name]
,[Country_ShortName]
FROM [dbo].vwCountries
WHERE [Active] = 1
order by isnull([Sort_order],99), [Country_id]