<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Wits Square</title>
	<atom:link href="http://source.witssquare.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://source.witssquare.com</link>
	<description>working with code stuff!...</description>
	<lastBuildDate>Fri, 22 Jan 2010 11:30:59 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>SQL Server &#8211; Indexed Views With Outer Joins</title>
		<link>http://source.witssquare.com/sql-server/sql-server-indexed-views-with-outer-joins/</link>
		<comments>http://source.witssquare.com/sql-server/sql-server-indexed-views-with-outer-joins/#comments</comments>
		<pubDate>Fri, 22 Jan 2010 11:29:41 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Index]]></category>
		<category><![CDATA[Index viewed with outer joins]]></category>
		<category><![CDATA[Indexed Views]]></category>
		<category><![CDATA[Views]]></category>

		<guid isPermaLink="false">http://source.witssquare.com/?p=293</guid>
		<description><![CDATA[Sometime ago I´m in trouble with a massive and large view. This monster was as slow a performing view as I&#8217;ve seen and I started to put in an effort to speed up the server and lower the response time.
First I considered creating some indexes on the view, but there a lot of limitations on [...]]]></description>
			<content:encoded><![CDATA[<p>Sometime ago I´m in trouble with a massive and large view. This monster was as slow a performing view as I&#8217;ve seen and I started to put in an effort to speed up the server and lower the response time.</p>
<p>First I considered creating some indexes on the view, but there a lot of limitations on indexed views. No unions, no sub-queries, no reference to other views and no OUTER JOINS! A legitimately needed left join was present in the view and any attempt to create a index raised a &#8220;not allowed construct&#8221; error. After hours of trial and error I managed to do it work. It&#8217;s not at all an elegant approach, but it works for outer joins. Unions, sub-queries and temporary tables can be emulated by these outer joins, and these can emulate them too.</p>
<h3>The Solution</h3>
<p>The idea is quite simple. Just emulate a outer join with a inner join! Swamp the outer join with a inner join and put a isnull(table_id,0) at one side of the comparison. The code below shows a full example:</p>
<p>CREATE TABLE Father<br />
(<br />
Father_id  smallint IDENTITY(1,1) PRIMARY KEY CLUSTERED,<br />
Father_Name varchar(50)<br />
)<br />
GO<br />
CREATE TABLE Son<br />
(<br />
Father_id  smallint, /*Foreign key*/<br />
Paternity varchar(50)<br />
)<br />
GO<br />
INSERT INTO Father values(&#8217;Father 1&#8242;)<br />
INSERT INTO Father values(&#8217;Father 2&#8242;)<br />
INSERT INTO Father values(&#8217;Father 3&#8242;)<br />
INSERT INTO Son values(1,&#8217;Child 1A of father 1&#8242;)<br />
INSERT INTO Son values(1,&#8217;Child 1B of father 1&#8242;)<br />
INSERT INTO Son values(2,&#8217;Child 2A of father 2&#8242;)<br />
INSERT INTO Son values(null,&#8217;Child 0X of no father&#8217;)<br />
GO<br />
/* Test your tables */<br />
SELECT f.father_id, f.father_name, s.father_id, s.paternity<br />
from father f<br />
INNER JOIN son s<br />
on s.father_id=f.father_id<br />
GO<br />
/* Test your tables twice*/<br />
SELECT f.father_id, f.father_name, s.father_id, s.paternity<br />
from father f<br />
LEFT JOIN son s<br />
on s.father_id=f.father_id<br />
/* Test your tables twice*/<br />
SELECT f.father_id, f.father_name, s.father_id, s.paternity<br />
from father f<br />
RIGHT JOIN son s<br />
on s.father_id=f.father_id<br />
GO<br />
/* Yep, do u need to put the owners names to bind the view to the schema */<br />
CREATE VIEW [dbo].[Family] WITH SCHEMABINDING<br />
AS<br />
/* Yes! You are right this is equal to the select example ; */<br />
SELECT f.father_id, f.father_name, s.father_id as son_id, s.paternity<br />
from [dbo].[father] f<br />
INNER JOIN [dbo].[son] s<br />
on isnull(s.father_id, -255)=f.father_id<br />
GO<br />
SELECT * FROM Family<br />
GO<br />
/* Hey!!! It not worked! We are forgetting one important thing to do   */<br />
/* we need a row at the father table to be the &#8220;null&#8221; or no father row */<br />
SET IDENTITY_INSERT Father ON<br />
INSERT INTO Father (Father_id, Father_name) values(-255,&#8217;No father&#8217;)<br />
SET IDENTITY_INSERT Father OFF<br />
GO<br />
/* Now create your indexes!!! */<br />
CREATE  UNIQUE  CLUSTERED  INDEX [Pk_Paternity]<br />
ON [dbo].[Family]([paternity])<br />
ON [PRIMARY]<br />
GO<br />
CREATE  INDEX [Pk_father_name]<br />
ON [dbo].[Family]([father_name])<br />
ON [PRIMARY]<br />
GO<br />
INSERT INTO Son values(2,&#8217;Child 2B of father 2&#8242;)<br />
INSERT INTO Son values(2,&#8217;Child 2C of father 2&#8242;)<br />
INSERT INTO Son values(null,&#8217;Child 0Y of no father&#8217;)<br />
INSERT INTO Son values(null,&#8217;Child 0Z of no father&#8217;)<br />
GO<br />
SELECT * FROM Family<br />
GO</p>
<h3>Conclusions</h3>
<p>Before your start to put indexes at all views, try use all your other tricks to enhance performance first. Use tables indices, normalization, disk IO, etc. Indexed views are one more tool at hand and this article is just one more tip to help you use them.</p>
]]></content:encoded>
			<wfw:commentRss>http://source.witssquare.com/sql-server/sql-server-indexed-views-with-outer-joins/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SQL SERVER – How to Drop Primary Key Contraint</title>
		<link>http://source.witssquare.com/sql-server/sql-server-%e2%80%93-how-to-drop-primary-key-contraint/</link>
		<comments>http://source.witssquare.com/sql-server/sql-server-%e2%80%93-how-to-drop-primary-key-contraint/#comments</comments>
		<pubDate>Thu, 21 Jan 2010 15:01:02 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[drop]]></category>
		<category><![CDATA[drop primary key]]></category>
		<category><![CDATA[Primary key]]></category>

		<guid isPermaLink="false">http://source.witssquare.com/?p=288</guid>
		<description><![CDATA[One area that always, unfailingly pulls my interest is SQL Server Errors and their solution. I enjoy the challenging task of passing through the maze of error to find a way out with a perfect solution. However, when I received the following error from one of my regular readers, I was a little stumped at [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">One area that always, unfailingly pulls my interest is SQL Server Errors and their solution. I enjoy the challenging task of passing through the maze of error to find a way out with a perfect solution. However, when I received the following error from one of my regular readers, I was a little stumped at first! After some online probing, I figured out that it was actually syntax from MySql and not SQL Server. The reader encountered error when he ran the following query.</p>
<p style="text-align: justify;"><code style="font-size: 12px;"><span style="color: blue;">ALTER TABLE </span><span style="color: black;">Table1<br />
</span><span style="color: blue;">DROP PRIMARY KEY<br />
</span><span style="color: black;">GO </span></code></p>
<p style="text-align: justify;"><span style="color: #ff0000;">Msg 156, Level 15, State 1, Line 3<br />
Incorrect syntax near the keyword ‘PRIMARY’.</span></p>
<p style="text-align: justify;">As mentioned earlier, this syntax is for MySql, not SQL Server. If you want to drop primary key constraint in SQL Server, run the following query.</p>
<p style="text-align: justify;"><code style="font-size: 12px;"><span style="color: blue;">ALTER TABLE </span><span style="color: black;">Table1<br />
</span><span style="color: blue;">DROP CONSTRAINT </span><span style="color: black;">PK_Table1_Col1<br />
GO </span></code></p>
<p style="text-align: justify;">Let us now pursue the complete example. First, we will create a table that has primary key. Next, we will drop the primary key successfully using the correct syntax of SQL Server.</p>
<p style="text-align: justify;"><code style="font-size: 12px;"><span style="color: blue;">CREATE TABLE </span><span style="color: black;">Table1</span><span style="color: gray;">(<br />
</span><span style="color: black;">Col1 </span><span style="color: blue;">INT </span><span style="color: gray;">NOT NULL,<br />
</span><span style="color: black;">Col2 </span><span style="color: blue;">VARCHAR</span><span style="color: gray;">(</span><span style="color: black;">100</span><span style="color: gray;">)<br />
</span><span style="color: blue;">CONSTRAINT </span><span style="color: black;">PK_Table1_Col1 </span><span style="color: blue;">PRIMARY KEY CLUSTERED </span><span style="color: gray;">(<br />
</span><span style="color: black;">Col1 </span><span style="color: blue;">ASC</span><span style="color: gray;">)<br />
)<br />
</span><span style="color: black;">GO<br />
</span><span style="color: green;"><br />
/* For SQL Server/Oracle/MS ACCESS */<br />
</span><span style="color: blue;">ALTER TABLE </span><span style="color: black;">Table1<br />
</span><span style="color: blue;">DROP CONSTRAINT </span><span style="color: black;">PK_Table1_Col1<br />
GO</span></code></p>
<p><code style="font-size: 12px;"><span style="color: green;">/* For MySql */<br />
</span><span style="color: blue;">ALTER TABLE </span><span style="color: black;">Table1<br />
</span><span style="color: blue;">DROP PRIMARY KEY<br />
</span><span style="color: black;">GO </span></code></p>
<p>sp_helptext &#8216;DBObjectName&#8217;</p>
<p>[Or]</p>
<p>select object_definition(object_id(&#8217;DBObjectName&#8217;))</p>
<p><span style="color: black;"><br />
</span></p>
]]></content:encoded>
			<wfw:commentRss>http://source.witssquare.com/sql-server/sql-server-%e2%80%93-how-to-drop-primary-key-contraint/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SQL SERVER – Primary Key Constraints and Unique Key Constraints</title>
		<link>http://source.witssquare.com/sql-server/sql-server-primary-key-constraints-and-unique-key-constraints/</link>
		<comments>http://source.witssquare.com/sql-server/sql-server-primary-key-constraints-and-unique-key-constraints/#comments</comments>
		<pubDate>Thu, 21 Jan 2010 14:57:40 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Primary key]]></category>
		<category><![CDATA[Primary key constraints]]></category>
		<category><![CDATA[Unique key]]></category>
		<category><![CDATA[Unique Key Constraints]]></category>

		<guid isPermaLink="false">http://source.witssquare.com/?p=286</guid>
		<description><![CDATA[Primary Key:
Primary Key enforces uniqueness of the column on which they are defined. Primary Key creates a clustered index on the column. Primary Key does not allow Nulls.
Create table with Primary Key:
CREATE TABLE Authors (
AuthorID INT NOT NULL PRIMARY KEY,
Name VARCHAR(100) NOT NULL
)
GO

Alter table with Primary Key:
ALTER TABLE Authors
ADD CONSTRAINT pk_authors PRIMARY KEY (AuthorID)
GO

Unique Key:
Unique [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;"><strong>Primary Key:</strong><br />
Primary Key enforces uniqueness of the column on which they are defined. Primary Key creates a clustered index on the column. Primary Key does not allow Nulls.</p>
<p style="text-align: justify;"><em>Create table with Primary Key:</em><br />
<code style="font-size: 12px;"><span style="color: blue;">CREATE TABLE </span><span style="color: black;">Authors </span><span style="color: gray;">(<br />
</span><span style="color: black;">AuthorID </span><span style="color: blue;">INT </span><span style="color: gray;">NOT NULL </span><span style="color: blue;">PRIMARY KEY</span><span style="color: gray;">,<br />
</span><span style="color: black;">Name </span><span style="color: blue;">VARCHAR</span><span style="color: gray;">(</span><span style="color: black;">100</span><span style="color: gray;">) NOT NULL<br />
)<br />
</span><span style="color: black;">GO<br />
</span></code><em><br />
Alter table with Primary Key:</em><br />
<code style="font-size: 12px;"><span style="color: blue;">ALTER TABLE </span><span style="color: black;">Authors<br />
</span><span style="color: blue;">ADD CONSTRAINT </span><span style="color: black;">pk_authors </span><span style="color: blue;">PRIMARY KEY </span><span style="color: gray;">(</span><span style="color: black;">AuthorID</span><span style="color: gray;">)<br />
</span><span style="color: black;">GO<br />
</span></code><br />
<strong>Unique Key:</strong><br />
Unique Key enforces uniqueness of the column on which they are defined. Unique Key creates a non-clustered index on the column. Unique Key allows only one NULL Value.</p>
<p><em>Alter table to add unique constraint to column:</em><br />
<code style="font-size: 12px;"><span style="color: blue;">ALTER TABLE </span><span style="color: black;">Authors </span><span style="color: blue;">ADD CONSTRAINT </span><span style="color: black;">IX_Authors_Name </span><span style="color: blue;">UNIQUE</span><span style="color: gray;">(</span><span style="color: black;">Name</span><span style="color: gray;">)<br />
</span><span style="color: black;">GO</span></code></p>
]]></content:encoded>
			<wfw:commentRss>http://source.witssquare.com/sql-server/sql-server-primary-key-constraints-and-unique-key-constraints/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Conditional(Ternary) Operator in C#</title>
		<link>http://source.witssquare.com/net/conditional-operator-in-c/</link>
		<comments>http://source.witssquare.com/net/conditional-operator-in-c/#comments</comments>
		<pubDate>Fri, 08 Jan 2010 05:54:02 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Conditional]]></category>
		<category><![CDATA[Conditional Operator in c#]]></category>
		<category><![CDATA[operator]]></category>
		<category><![CDATA[using conditional operator in c#]]></category>

		<guid isPermaLink="false">http://source.witssquare.com/?p=281</guid>
		<description><![CDATA[Often times in code you want to assign one variable to another, but only if the variable is not null. If it is null, you want to populate the target variable with another ( perhaps default ) value. The code normally may look like this using the C# Conditional Operator:
string fileName = tempFileName != null [...]]]></description>
			<content:encoded><![CDATA[<p>Often times in code you want to assign one variable to another, but only if the variable is not null. If it is null, you want to populate the target variable with another ( perhaps default ) value. The code normally may look like this using the C# Conditional Operator:</p>
<p><strong><span style="color: #0000ff;">string </span>fileName = tempFileName != <span style="color: #0000ff;">null </span>? tempFileName : <span style="color: #800000;">&#8220;Untitled&#8221;</span>;</strong></p>
<p>If tempFileName is not null, fileName = tempFileName, <span style="color: #0000ff;">else </span>fileName =<span style="color: #800000;"> “Untitled“</span>.</p>
<p>This can now be abbreviated as follows using the Null-Coalescing Operator:</p>
<p><strong><span style="color: #0000ff;">string </span>fileName = tempFileName ?? <span style="color: #800000;">&#8220;Untitled&#8221;</span>;</strong></p>
<p>The logic is the same. If tempFileName is not null, fileName = tempFileName, else fileName = “Untitled“.</p>
<p>The Null-Coalescing Operator comes up a lot with nullable types, particular when converting from a nullable type to its value type:</p>
<p><strong><span style="color: #0000ff;">int</span>? count = <span style="color: #0000ff;">null</span>;</strong><br />
<strong><br />
<span style="color: #0000ff;">int </span>amount = count ??<span style="color: #0000ff;"> default</span>(<span style="color: #0000ff;">int</span>);</strong></p>
<p>Since count is null, amount will now be the default value of an integer type ( zero ).</p>
<p>These Conditional and Null-Coalescing Operators aren&#8217;t the most self-describing operators <img src='http://source.witssquare.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> , but I do love programming in C#!</p>
<p><strong><span style="color: #808080;">Reference : <a href="http://source.witssquare.com/" target="_self">http://source.witssquare.com</a></span></strong></p>
]]></content:encoded>
			<wfw:commentRss>http://source.witssquare.com/net/conditional-operator-in-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Retrieve Current Date Time in SQL Server CURRENT_TIMESTAMP, GETDATE(), {fn NOW()}</title>
		<link>http://source.witssquare.com/sql-server/retrieve-current-date-time-in-sql-server-current_timestamp-getdate-fn-now/</link>
		<comments>http://source.witssquare.com/sql-server/retrieve-current-date-time-in-sql-server-current_timestamp-getdate-fn-now/#comments</comments>
		<pubDate>Wed, 23 Dec 2009 14:31:37 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[CURRENT_TIMESTAMP]]></category>
		<category><![CDATA[datetime]]></category>
		<category><![CDATA[getdate()]]></category>
		<category><![CDATA[Reterive Current datetime]]></category>
		<category><![CDATA[{fn NOW()}]]></category>

		<guid isPermaLink="false">http://source.witssquare.com/?p=272</guid>
		<description><![CDATA[There are three ways to retrieve the current datetime in SQL SERVER.
 CURRENT_TIMESTAMP, GETDATE(), {fn NOW()}
CURRENT_TIMESTAMP
CURRENT_TIMESTAMP is a nondeterministic function. Views and expressions that reference this column cannot be indexed. CURRENT_TIMESTAMP can be used to print the current date and time every time that the report is produced.
GETDATE()
GETDATE is a nondeterministic function. Views and expressions [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">There are three ways to retrieve the current datetime in SQL SERVER.<br />
<em> CURRENT_TIMESTAMP, GETDATE(), {fn NOW()}</em></p>
<p style="text-align: justify;"><strong>CURRENT_TIMESTAMP</strong><br />
CURRENT_TIMESTAMP is a nondeterministic function. Views and expressions that reference this column cannot be indexed. CURRENT_TIMESTAMP can be used to print the current date and time every time that the report is produced.</p>
<p style="text-align: justify;"><strong>GETDATE()</strong><br />
GETDATE is a nondeterministic function. Views and expressions that reference this column cannot be indexed. GETDATE can be used to print the current date and time every time that the report is produced.</p>
<p style="text-align: justify;"><strong>{fn Now()}</strong><br />
The {fn Now()} is an ODBC canonical function which can be used in T-SQL since the OLE DB provider for SQL Server supports them. {fn Now()} can be used to print the current date and time every time that the report is produced.</p>
<p style="text-align: justify;">If you run following script in Query Analyzer. I will give you same results. If you see execution plan there is no performance difference. It is same for all the three select statement.<br />
<code style="font-size: 12px;"><span style="color: blue;">SELECT </span><span style="color: magenta;">CURRENT_TIMESTAMP<br />
</span><span style="color: black;">GO<br />
</span><span style="color: blue;">SELECT </span><span style="color: black;">{fn NOW</span><span style="color: gray;">()</span><span style="color: black;">}<br />
GO<br />
</span><span style="color: blue;">SELECT </span><span style="color: magenta;">GETDATE</span><span style="color: gray;">()<br />
</span><span style="color: black;">GO<br />
</span></code><br />
<strong>Performance:</strong><br />
There is absolutely no difference in using any of them. As they are absolutely same.</p>
<p style="text-align: justify;"><strong>My Preference:</strong><br />
I like GETDATE(). Why? Why bother when they are same!!!</p>
<p style="text-align: justify;"><span style="text-decoration: line-through;"><span style="color: #008000;"><strong>Convert Date Format for like this [dd-MMM-yyyy].</strong></span></span></p>
<p><span style="color: #0000ff;">Select </span><span style="color: #ff00ff;">Substring</span>(<span style="color: #ff00ff;">Convert</span>(<span style="color: #0000ff;">Varchar</span>(10),<span style="color: #ff00ff;">getdate</span>(),111), <span style="color: #ff00ff;">Len</span>(<span style="color: #ff00ff;">Convert</span>(<span style="color: #0000ff;">Varchar</span>(10),<span style="color: #ff00ff;">getdate</span>(),111))-1,2) + &#8216;-&#8217; +<br />
<span style="color: #ff00ff;">Substring</span>(<span style="color: #ff00ff;">Convert</span>(<span style="color: #0000ff;">Varchar</span>(20),<span style="color: #ff00ff;">getdate</span>(),0),1,3) + &#8216;-&#8217; + <span style="color: #ff00ff;">Substring</span>(<span style="color: #ff00ff;">Convert</span>(<span style="color: #0000ff;">Varchar</span>(10),<span style="color: #ff00ff;">getdate</span>(),111),1,4)<span style="color: #0000ff;">As</span> Date</p>
]]></content:encoded>
			<wfw:commentRss>http://source.witssquare.com/sql-server/retrieve-current-date-time-in-sql-server-current_timestamp-getdate-fn-now/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Difference between Get and Post Method</title>
		<link>http://source.witssquare.com/net/difference-between-get-and-post-method/</link>
		<comments>http://source.witssquare.com/net/difference-between-get-and-post-method/#comments</comments>
		<pubDate>Fri, 11 Dec 2009 07:16:22 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Difference between Get and Post Method]]></category>
		<category><![CDATA[get]]></category>
		<category><![CDATA[method]]></category>
		<category><![CDATA[Method="get"]]></category>
		<category><![CDATA[Method="post"]]></category>
		<category><![CDATA[post]]></category>

		<guid isPermaLink="false">http://source.witssquare.com/?p=268</guid>
		<description><![CDATA[1. As per functionality both GET and POST methods were same.Difference is GET  method will be showing the information information to the users.But in the case  of POST method information will not be shown to the user.
2. The data  passed using the GET method would be visible to the user of the [...]]]></description>
			<content:encoded><![CDATA[<p><span style="color: #ff0000;"><strong>1. </strong></span>As per functionality both GET and POST methods were same.Difference is GET  method will be showing the information information to the users.But in the case  of POST method information will not be shown to the user.</p>
<p><span style="color: #ff0000;"><strong>2.</strong></span> The data  passed using the GET method would be visible to the user of the website in the  browser address bar but when we pass the information using the POST method the  data is not visible to the user directly.</p>
<p><span style="color: #ff0000;"><strong>3.</strong></span> Also in GET method  characters were restricted only to 256 characters.But in the case of POST method  characters were not restricted.<br />
Get method will be visible to the user as it  sended appended to the UML, put Post will not be visible as it is sent  encapsulated within the HTTP request body.</p>
<p><span style="color: #ff0000;"><strong>4.</strong></span> About the data type that  can be send, with Get method you can only use text as it sent as a string  appended with the URL, but with post is can text or binary.</p>
<p><span style="color: #ff0000;"><strong>5.</strong></span> About form  default, Get is the defualt method for any form, if you need to use the post  method, you have to change the value of the attribute &#8220;method&#8221; to be  Post.</p>
<p>Get method has maximum length restricted to 256 characters as  it is sent appended with the URL, but the Post method hasn&#8217;t.</p>
<p>Reference :<a href="http://source.witssquare.com" target="_self"> http://source.witssquare.com</a></p>
]]></content:encoded>
			<wfw:commentRss>http://source.witssquare.com/net/difference-between-get-and-post-method/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Client Side Validation with JavaScript using ASP.NET</title>
		<link>http://source.witssquare.com/net/client-side-validation-with-javascript-using-asp-net/</link>
		<comments>http://source.witssquare.com/net/client-side-validation-with-javascript-using-asp-net/#comments</comments>
		<pubDate>Tue, 17 Nov 2009 05:08:15 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Java Script]]></category>
		<category><![CDATA[VB.NET]]></category>
		<category><![CDATA[client side validation]]></category>
		<category><![CDATA[Client Side Validation with JavaScript using ASP.NET]]></category>
		<category><![CDATA[email validation in javascript]]></category>
		<category><![CDATA[java script validation]]></category>
		<category><![CDATA[name validation]]></category>
		<category><![CDATA[postal code validation using javascript]]></category>
		<category><![CDATA[validation]]></category>
		<category><![CDATA[web url validation]]></category>
		<category><![CDATA[zipcode]]></category>

		<guid isPermaLink="false">http://source.witssquare.com/?p=264</guid>
		<description><![CDATA[This simple program will guide how to do client side validation of Form in JavaScript.
In this just make a form as follows:

Name : &#60;asp:TextBox ID=&#8221;txtName&#8221; /&#62;
Email : &#60;asp:TextBox ID=&#8221;txtEmail&#8221; /&#62;
Web URL : &#60;asp:TextBox ID=&#8221;txtWebUrl&#8221; /&#62;
Zip : &#60;asp:TextBox ID=&#8221;txtZip&#8221; /&#62;
 &#60;asp:Button ID=&#8221;btnSubmit&#8221; OnClientClick=&#8221; return validate()&#8221; runat=&#8221;server&#8221; Text=&#8221;Submit&#8221; /&#62;


Now on the source code of this form in [...]]]></description>
			<content:encoded><![CDATA[<p><span style="font-size: x-small;"><span style="font-family: Verdana,Arial,Helvetica,sans-serif;">This simple program will guide how to do client side validation of Form in JavaScript.</span></span></p>
<p><span style="font-size: x-small;"><span style="font-family: Verdana,Arial,Helvetica,sans-serif;">In this just make a form as follows:</span></span></p>
<ol><span style="font-size: x-small;"></p>
<li><span style="font-family: Verdana,Arial,Helvetica,sans-serif;">Name : <span style="color: #0000ff; font-size: x-small;">&lt;</span><span style="color: #800000; font-size: x-small;">asp</span><span style="color: #0000ff; font-size: x-small;">:</span><span style="color: #800000; font-size: x-small;">TextBox</span><span style="font-size: x-small;"> </span><span style="color: #ff0000; font-size: x-small;">ID</span><span style="color: #0000ff; font-size: x-small;">=&#8221;txtName&#8221;</span><span style="font-size: x-small;"> </span><span style="color: #0000ff; font-size: x-small;">/&gt;</span></span></li>
<li><span style="font-family: Verdana,Arial,Helvetica,sans-serif;">Email : <span style="color: #0000ff; font-size: x-small;">&lt;</span><span style="color: #800000; font-size: x-small;">asp</span><span style="color: #0000ff; font-size: x-small;">:</span><span style="color: #800000; font-size: x-small;">TextBox</span><span style="font-size: x-small;"> </span><span style="color: #ff0000; font-size: x-small;">ID</span><span style="color: #0000ff; font-size: x-small;">=&#8221;txtEmail&#8221;</span><span style="font-size: x-small;"> </span><span style="color: #0000ff; font-size: x-small;">/&gt;</span></span></li>
<li><span style="font-family: Verdana,Arial,Helvetica,sans-serif;">Web URL : <span style="color: #0000ff; font-size: x-small;">&lt;</span><span style="color: #800000; font-size: x-small;">asp</span><span style="color: #0000ff; font-size: x-small;">:</span><span style="color: #800000; font-size: x-small;">TextBox</span><span style="font-size: x-small;"> </span><span style="color: #ff0000; font-size: x-small;">ID</span><span style="color: #0000ff; font-size: x-small;">=&#8221;txtWebUrl&#8221;</span><span style="font-size: x-small;"> </span><span style="color: #0000ff; font-size: x-small;">/&gt;</span></span></li>
<li><span style="font-family: Verdana,Arial,Helvetica,sans-serif;">Zip : <span style="color: #0000ff; font-size: x-small;">&lt;</span><span style="color: #800000; font-size: x-small;">asp</span><span style="color: #0000ff; font-size: x-small;">:</span><span style="color: #800000; font-size: x-small;">TextBox</span><span style="font-size: x-small;"> </span><span style="color: #ff0000; font-size: x-small;">ID</span><span style="color: #0000ff; font-size: x-small;">=&#8221;txtZip&#8221;</span><span style="font-size: x-small;"> </span><span style="color: #0000ff; font-size: x-small;">/&gt;</span></span></li>
<li><span style="font-family: Verdana,Arial,Helvetica,sans-serif;"><span style="color: #0000ff; font-size: x-small;"> </span><span style="color: #0000ff; font-size: x-small;">&lt;</span><span style="color: #800000; font-size: x-small;">asp</span><span style="color: #0000ff; font-size: x-small;">:</span><span style="color: #800000; font-size: x-small;">Button</span><span style="font-size: x-small;"> </span><span style="color: #ff0000; font-size: x-small;">ID</span><span style="color: #0000ff; font-size: x-small;">=&#8221;btnSubmit&#8221;</span><span style="font-size: x-small;"> </span><span style="color: #ff0000; font-size: x-small;">OnClientClick</span><span style="color: #0000ff; font-size: x-small;">=&#8221; return validate()&#8221;</span><span style="font-size: x-small;"> </span><span style="color: #ff0000; font-size: x-small;">runat</span><span style="color: #0000ff; font-size: x-small;">=&#8221;server&#8221;</span><span style="font-size: x-small;"> </span><span style="color: #ff0000; font-size: x-small;">Text</span><span style="color: #0000ff; font-size: x-small;">=&#8221;Submit&#8221;</span><span style="font-size: x-small;"> </span><span style="color: #0000ff; font-size: x-small;">/&gt;</span>
<p></span></li>
<p></span></ol>
<p><span style="font-size: x-small;"><span style="font-family: Verdana,Arial,Helvetica,sans-serif;">Now on the source code of this form in script tag write the following code:</span></span></p>
<p><span style="font-size: x-small;"><span style="color: #0000ff; font-size: x-small;"> </span></span></p>
<p><span style="font-size: x-small;"><span style="color: #0000ff; font-size: x-small;"><span style="font-family: Verdana,Arial,Helvetica,sans-serif;">&lt;</span></span><span style="font-family: Verdana,Arial,Helvetica,sans-serif;"><span style="color: #800000; font-size: x-small;">script</span><span style="font-size: x-small;"> </span><span style="color: #ff0000; font-size: x-small;">language</span><span style="color: #0000ff; font-size: x-small;">=&#8221;javascript&#8221;</span><span style="font-size: x-small;"> </span><span style="color: #ff0000; font-size: x-small;">type</span></span><span style="font-family: Verdana,Arial,Helvetica,sans-serif; color: #0000ff; font-size: x-small;">=&#8221;text/javascript&#8221;&gt;<br />
function</span><span style="font-family: Verdana,Arial,Helvetica,sans-serif;"><span style="font-size: x-small;"> validate()<br />
{<br />
</span><span style="color: #0000ff; font-size: x-small;"> if</span><span style="font-size: x-small;"> (document.getElementById(</span><span style="color: #800000; font-size: x-small;">&#8220;&lt;%=txtName.ClientID%&gt;&#8221;</span><span style="font-size: x-small;">).value==</span><span style="color: #800000; font-size: x-small;">&#8220;&#8221;</span></span><span style="font-family: Verdana,Arial,Helvetica,sans-serif;"><span style="font-size: x-small;">)<br />
{<br />
</span><span style="font-size: x-small;"> alert(</span><span style="color: #800000; font-size: x-small;">&#8220;Name Feild can not be blank&#8221;</span></span><span style="font-family: Verdana,Arial,Helvetica,sans-serif;"><span style="font-size: x-small;">);<br />
document.getElementById(</span><span style="color: #800000; font-size: x-small;">&#8220;&lt;%=txtName.ClientID%&gt;&#8221;</span></span><span style="font-family: Verdana,Arial,Helvetica,sans-serif;"><span style="font-size: x-small;">).focus();<br />
</span><span style="color: #0000ff; font-size: x-small;"> return</span><span style="font-size: x-small;"> </span><span style="color: #0000ff; font-size: x-small;">false</span></span><span style="font-family: Verdana,Arial,Helvetica,sans-serif;"><span style="font-size: x-small;">;<br />
}<br />
</span><span style="color: #0000ff; font-size: x-small;"> if</span><span style="font-size: x-small;">(document.getElementById(</span><span style="color: #800000; font-size: x-small;">&#8220;&lt;%=txtEmail.ClientID %&gt;&#8221;</span><span style="font-size: x-small;">).value==</span><span style="color: #800000; font-size: x-small;">&#8220;&#8221;</span></span><span style="font-family: Verdana,Arial,Helvetica,sans-serif;"><span style="font-size: x-small;">)<br />
{<br />
alert(</span><span style="color: #800000; font-size: x-small;">&#8220;Email id can not be blank&#8221;</span></span><span style="font-family: Verdana,Arial,Helvetica,sans-serif;"><span style="font-size: x-small;">);<br />
</span><span style="font-size: x-small;"> document.getElementById(</span><span style="color: #800000; font-size: x-small;">&#8220;&lt;%=txtEmail.ClientID %&gt;&#8221;</span></span><span style="font-family: Verdana,Arial,Helvetica,sans-serif;"><span style="font-size: x-small;">).focus();<br />
</span><span style="color: #0000ff; font-size: x-small;"> return</span><span style="font-size: x-small;"> </span><span style="color: #0000ff; font-size: x-small;">false</span></span><span style="font-family: Verdana,Arial,Helvetica,sans-serif;"><span style="font-size: x-small;">;<br />
}<br />
</span><span style="color: #0000ff; font-size: x-small;"> var</span></span><span style="font-family: Verdana,Arial,Helvetica,sans-serif;"><span style="font-size: x-small;"> emailPat = /^(\&#8221;.*\&#8221;|[A-Za-z]\w*)@(\[\d{1,3}(\.\d{1,3}){3}]|[A-Za-z]\w*(\.[A-Za-z]\w*)+)$/;<br />
</span><span style="color: #0000ff; font-size: x-small;"> var</span><span style="font-size: x-small;"> emailid=document.getElementById(</span><span style="color: #800000; font-size: x-small;">&#8220;&lt;%=txtEmail.ClientID %&gt;&#8221;</span></span><span style="font-family: Verdana,Arial,Helvetica,sans-serif;"><span style="font-size: x-small;">).value;<br />
</span><span style="color: #0000ff; font-size: x-small;"> var</span></span><span style="font-family: Verdana,Arial,Helvetica,sans-serif;"><span style="font-size: x-small;"> matchArray = emailid.match(emailPat);<br />
</span><span style="color: #0000ff; font-size: x-small;"> if</span><span style="font-size: x-small;"> (matchArray == </span><span style="color: #0000ff; font-size: x-small;">null</span></span><span style="font-family: Verdana,Arial,Helvetica,sans-serif;"><span style="font-size: x-small;">)<br />
{<br />
alert(</span><span style="color: #800000; font-size: x-small;">&#8220;Your email address seems incorrect. Please try again.&#8221;</span></span><span style="font-family: Verdana,Arial,Helvetica,sans-serif;"><span style="font-size: x-small;">);<br />
document.getElementById(</span><span style="color: #800000; font-size: x-small;">&#8220;&lt;%=txtEmail.ClientID %&gt;&#8221;</span></span><span style="font-family: Verdana,Arial,Helvetica,sans-serif;"><span style="font-size: x-small;">).focus();<br />
</span><span style="color: #0000ff; font-size: x-small;"> return</span><span style="font-size: x-small;"> </span><span style="color: #0000ff; font-size: x-small;">false</span></span><span style="font-family: Verdana,Arial,Helvetica,sans-serif;"><span style="font-size: x-small;">;<br />
}<br />
</span><span style="color: #0000ff; font-size: x-small;"> if</span><span style="font-size: x-small;">(document.getElementById(</span><span style="color: #800000; font-size: x-small;">&#8220;&lt;%=txtWebURL.ClientID %&gt;&#8221;</span><span style="font-size: x-small;">).value==</span><span style="color: #800000; font-size: x-small;">&#8220;&#8221;</span></span><span style="font-family: Verdana,Arial,Helvetica,sans-serif;"><span style="font-size: x-small;">)<br />
{<br />
alert(</span><span style="color: #800000; font-size: x-small;">&#8220;Web URL can not be blank&#8221;</span></span><span style="font-family: Verdana,Arial,Helvetica,sans-serif;"><span style="font-size: x-small;">);<br />
document.getElementById(</span><span style="color: #800000; font-size: x-small;">&#8220;&lt;%=txtWebURL.ClientID %&gt;&#8221;</span><span style="font-size: x-small;">).value=</span></span><span style="font-family: Verdana,Arial,Helvetica,sans-serif;"><span style="color: #800000; font-size: x-small;">&#8220;http://&#8221;<br />
</span><span style="font-size: x-small;"> document.getElementById(</span><span style="color: #800000; font-size: x-small;">&#8220;&lt;%=txtWebURL.ClientID %&gt;&#8221;</span></span><span style="font-family: Verdana,Arial,Helvetica,sans-serif;"><span style="font-size: x-small;">).focus();<br />
</span><span style="color: #0000ff; font-size: x-small;"> return</span><span style="font-size: x-small;"> </span><span style="color: #0000ff; font-size: x-small;">false</span></span><span style="font-family: Verdana,Arial,Helvetica,sans-serif;"><span style="font-size: x-small;">;<br />
}<br />
</span><span style="color: #0000ff; font-size: x-small;"> var</span><span style="font-size: x-small;"> Url=</span></span><span style="font-family: Verdana,Arial,Helvetica,sans-serif;"><span style="color: #800000; font-size: x-small;">&#8220;^[A-Za-z]+://[A-Za-z0-9-_]+\\.[A-Za-z0-9-_%&amp;\?\/.=]+$&#8221;<br />
</span><span style="color: #0000ff; font-size: x-small;"> var</span><span style="font-size: x-small;"> tempURL=document.getElementById(</span><span style="color: #800000; font-size: x-small;">&#8220;&lt;%=txtWebURL.ClientID%&gt;&#8221;</span></span><span style="font-family: Verdana,Arial,Helvetica,sans-serif;"><span style="font-size: x-small;">).value;<br />
</span><span style="color: #0000ff; font-size: x-small;"> var</span></span><span style="font-family: Verdana,Arial,Helvetica,sans-serif;"><span style="font-size: x-small;"> matchURL=tempURL.match(Url);<br />
</span><span style="color: #0000ff; font-size: x-small;"> if</span><span style="font-size: x-small;">(matchURL==</span><span style="color: #0000ff; font-size: x-small;">null</span></span><span style="font-family: Verdana,Arial,Helvetica,sans-serif;"><span style="font-size: x-small;">)<br />
{<br />
alert(</span><span style="color: #800000; font-size: x-small;">&#8220;Web URL does not look valid&#8221;</span></span><span style="font-family: Verdana,Arial,Helvetica,sans-serif;"><span style="font-size: x-small;">);<br />
document.getElementById(</span><span style="color: #800000; font-size: x-small;">&#8220;&lt;%=txtWebURL.ClientID %&gt;&#8221;</span></span><span style="font-family: Verdana,Arial,Helvetica,sans-serif;"><span style="font-size: x-small;">).focus();<br />
</span><span style="color: #0000ff; font-size: x-small;"> return</span><span style="font-size: x-small;"> </span><span style="color: #0000ff; font-size: x-small;">false</span></span><span style="font-family: Verdana,Arial,Helvetica,sans-serif;"><span style="font-size: x-small;">;<br />
}<br />
</span><span style="color: #0000ff; font-size: x-small;"> if</span><span style="font-size: x-small;"> (document.getElementById(</span><span style="color: #800000; font-size: x-small;">&#8220;&lt;%=txtZIP.ClientID%&gt;&#8221;</span><span style="font-size: x-small;">).value==</span><span style="color: #800000; font-size: x-small;">&#8220;&#8221;</span></span><span style="font-family: Verdana,Arial,Helvetica,sans-serif;"><span style="font-size: x-small;">)<br />
{<br />
alert(</span><span style="color: #800000; font-size: x-small;">&#8220;Zip Code is not valid&#8221;</span></span><span style="font-family: Verdana,Arial,Helvetica,sans-serif;"><span style="font-size: x-small;">);<br />
document.getElementById(</span><span style="color: #800000; font-size: x-small;">&#8220;&lt;%=txtZIP.ClientID%&gt;&#8221;</span></span><span style="font-family: Verdana,Arial,Helvetica,sans-serif;"><span style="font-size: x-small;">).focus();<br />
</span><span style="color: #0000ff; font-size: x-small;"> return</span><span style="font-size: x-small;"> </span><span style="color: #0000ff; font-size: x-small;">false</span></span><span style="font-family: Verdana,Arial,Helvetica,sans-serif;"><span style="font-size: x-small;">;<br />
}<br />
</span><span style="color: #0000ff; font-size: x-small;"> var</span><span style="font-size: x-small;"> digits=</span><span style="color: #800000; font-size: x-small;">&#8220;0123456789&#8243;</span></span><span style="font-family: Verdana,Arial,Helvetica,sans-serif;"><span style="font-size: x-small;">;<br />
</span><span style="color: #0000ff; font-size: x-small;"> var</span></span><span style="font-family: Verdana,Arial,Helvetica,sans-serif;"><span style="font-size: x-small;"> temp;<br />
</span><span style="color: #0000ff; font-size: x-small;"> for</span><span style="font-size: x-small;"> (</span><span style="color: #0000ff; font-size: x-small;">var</span><span style="font-size: x-small;"> i=0;i&lt;document.getElementById(</span><span style="color: #800000; font-size: x-small;">&#8220;&lt;%=txtZIP.ClientID %&gt;&#8221;</span></span><span style="font-family: Verdana,Arial,Helvetica,sans-serif;"><span style="font-size: x-small;">).value.length;i++)<br />
{<br />
temp=document.getElementById(</span><span style="color: #800000; font-size: x-small;">&#8220;&lt;%=txtZIP.ClientID%&gt;&#8221;</span></span><span style="font-family: Verdana,Arial,Helvetica,sans-serif;"><span style="font-size: x-small;">).value.substring(i,i+1);<br />
</span><span style="color: #0000ff; font-size: x-small;"> if</span></span><span style="font-family: Verdana,Arial,Helvetica,sans-serif;"><span style="font-size: x-small;"> (digits.indexOf(temp)==-1)<br />
{<br />
alert(</span><span style="color: #800000; font-size: x-small;">&#8220;Please enter correct zip code&#8221;</span></span><span style="font-family: Verdana,Arial,Helvetica,sans-serif;"><span style="font-size: x-small;">);<br />
document.getElementById(</span><span style="color: #800000; font-size: x-small;">&#8220;&lt;%=txtZIP.ClientID%&gt;&#8221;</span></span><span style="font-family: Verdana,Arial,Helvetica,sans-serif;"><span style="font-size: x-small;">).focus();<br />
</span><span style="color: #0000ff; font-size: x-small;"> return</span><span style="font-size: x-small;"> </span><span style="color: #0000ff; font-size: x-small;">false</span></span><span style="font-family: Verdana,Arial,Helvetica,sans-serif;"><span style="font-size: x-small;">;<br />
}<br />
}<br />
</span><span style="color: #0000ff; font-size: x-small;"> return</span><span style="font-size: x-small;"> </span><span style="color: #0000ff; font-size: x-small;">true</span></span><span style="font-family: Verdana,Arial,Helvetica,sans-serif;"><span style="font-size: x-small;">;<br />
}<br />
</span><span style="color: #0000ff; font-size: x-small;">&lt;/</span><span style="color: #800000; font-size: x-small;">script</span><span style="color: #0000ff; font-size: x-small;">&gt;</span></span></span></p>
<p><span style="font-size: x-small;"> </span></p>
<p><span style="font-size: x-small;"><span style="font-family: Verdana,Arial,Helvetica,sans-serif;">And in code behind file just write the below code.</span></span></p>
<p><span style="font-size: x-small;"><span style="font-family: Verdana,Arial,Helvetica,sans-serif;">In C#,</span></span></p>
<p><span style="font-size: x-small;"><span style="font-family: Verdana,Arial,Helvetica,sans-serif;"><span style="color: #0000ff; font-size: x-small;"> </span></span></span><span style="color: #0000ff;">protected void </span>Page_Load(<span style="color: #0000ff;">object </span>sender, System.<span style="color: #008080;">EventArgs</span> e)<br />
{</p>
<p><span style="font-size: x-small;"><span style="font-family: Verdana,Arial,Helvetica,sans-serif;"><span style="font-size: x-small;"> btnSubmit.Attributes.Add(</span><span style="color: #800000; font-size: x-small;">&#8220;onclick&#8221;</span><span style="font-size: x-small;">, </span><span style="color: #800000; font-size: x-small;">&#8220;return validate()&#8221;</span></span><span style="font-family: Verdana,Arial,Helvetica,sans-serif;"><span style="font-size: x-small;">);</span></span></span></p>
<p>}</p>
<p><span style="font-size: x-small;"><span style="font-family: Verdana,Arial,Helvetica,sans-serif;">In VB,<br />
</span></span></p>
<p><span style="font-size: x-small;"><span style="font-size: x-small;"> </span></span></p>
<p><span style="font-size: x-small;"><span style="font-family: Verdana,Arial,Helvetica,sans-serif;"><span style="color: #0000ff; font-size: x-small;">Protected</span><span style="font-size: x-small;"> </span><span style="color: #0000ff; font-size: x-small;">Sub</span><span style="font-size: x-small;"> Page_Load(</span><span style="color: #0000ff; font-size: x-small;">ByVal</span><span style="font-size: x-small;"> sender </span><span style="color: #0000ff; font-size: x-small;">As</span><span style="font-size: x-small;"> </span><span style="color: #0000ff; font-size: x-small;">Object</span><span style="font-size: x-small;">, </span><span style="color: #0000ff; font-size: x-small;">ByVal</span><span style="font-size: x-small;"> e </span><span style="color: #0000ff; font-size: x-small;">As</span><span style="font-size: x-small;"> System.EventArgs) </span><span style="color: #0000ff; font-size: x-small;">Handles</span><span style="font-size: x-small;"> </span><span style="color: #0000ff; font-size: x-small;">Me</span></span><span style="font-family: Verdana,Arial,Helvetica,sans-serif;"><span style="font-size: x-small;">.Load<br />
btnSubmit.Attributes.Add(</span><span style="color: #800000; font-size: x-small;">&#8220;onclick&#8221;</span><span style="font-size: x-small;">, </span><span style="color: #800000; font-size: x-small;">&#8220;return validate()&#8221;</span></span><span style="font-family: Verdana,Arial,Helvetica,sans-serif;"><span style="font-size: x-small;">)<br />
</span><span style="color: #0000ff; font-size: x-small;">End</span><span style="font-size: x-small;"> </span><span style="color: #0000ff; font-size: x-small;">Sub</span></span></span></p>
<p><span style="font-size: x-small;"><span style="font-family: Verdana,Arial,Helvetica,sans-serif;"><span style="color: #0000ff; font-size: x-small;"><strong>Reference : <a href="http://source.witssquare.com" target="_self">http://source.witssquare.com</a></strong><br />
</span></span></span></p>
]]></content:encoded>
			<wfw:commentRss>http://source.witssquare.com/net/client-side-validation-with-javascript-using-asp-net/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WCF,WPF and WWF in .Net</title>
		<link>http://source.witssquare.com/net/wcf-wpf-wwf-in-net/</link>
		<comments>http://source.witssquare.com/net/wcf-wpf-wwf-in-net/#comments</comments>
		<pubDate>Fri, 13 Nov 2009 09:49:14 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[advance concept in visual studio 2008]]></category>
		<category><![CDATA[c#.net]]></category>
		<category><![CDATA[WCF]]></category>
		<category><![CDATA[what is WCF]]></category>
		<category><![CDATA[what is wpf]]></category>
		<category><![CDATA[what is wwf]]></category>
		<category><![CDATA[Windows communcation funcation]]></category>
		<category><![CDATA[Windows Workflow Foundation]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[WPF and WWF in .Net]]></category>
		<category><![CDATA[WWF]]></category>
		<category><![CDATA[•	Windows Presentation Framework]]></category>

		<guid isPermaLink="false">http://source.witssquare.com/?p=255</guid>
		<description><![CDATA[What Is Windows Communication Foundation?
The global acceptance of Web services, which includes standard protocols for application-to-application communication, has changed software development. For example, the functions that Web services now provide include security, distributed transaction coordination, and reliable communication. The benefits of the changes in Web services should be reflected in the tools and technologies that [...]]]></description>
			<content:encoded><![CDATA[<p><strong>What Is Windows Communication Foundation?</strong></p>
<p>The global acceptance of Web services, which includes standard protocols for application-to-application communication, has changed software development. For example, the functions that Web services now provide include security, distributed transaction coordination, and reliable communication. The benefits of the changes in Web services should be reflected in the tools and technologies that developers use. Windows Communication Foundation (WCF)&#8230;</p>
<p><a href="../wp-content/uploads/2009/11/WCFWPFWWF.pdf" target="_blank"><span style="text-decoration: underline;"> </span></a><a href="http://source.witssquare.com/wp-content/uploads/2009/11/WCFWPFWWF.pdf" target="_blank">Read more&#8230;</a></p>
<p><strong>Reference : <a href="http://source.witssquare.com/" target="_self">http://source.witssquare.com/</a></strong></p>
]]></content:encoded>
			<wfw:commentRss>http://source.witssquare.com/net/wcf-wpf-wwf-in-net/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Reading Excel Sheet Names in C#</title>
		<link>http://source.witssquare.com/net/reading-excel-sheet-names-in-c-sharp/</link>
		<comments>http://source.witssquare.com/net/reading-excel-sheet-names-in-c-sharp/#comments</comments>
		<pubDate>Fri, 13 Nov 2009 05:11:29 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[excel]]></category>
		<category><![CDATA[excel sheet name]]></category>
		<category><![CDATA[how to read excel sheet name]]></category>
		<category><![CDATA[how to read excel sheet names in c#]]></category>
		<category><![CDATA[read excel sheet name]]></category>

		<guid isPermaLink="false">http://source.witssquare.com/?p=246</guid>
		<description><![CDATA[The code sample defines a function GetExcelSheetNames that takes an Excel file&#8217;s path as input, opens it, and find out the sheet names in that file.
The function uses a OleDbConnection to connect to the data source (the excel file). The file is is referred by a DataTable and each row in this DataTable is a [...]]]></description>
			<content:encoded><![CDATA[<p><span style="color: #333333;"><span id="ctl00_ContentPlaceHolder1_lblDescription">The code sample defines a function GetExcelSheetNames that takes an Excel file&#8217;s path as input, opens it, and find out the sheet names in that file.</span></span></p>
<p>The function uses a OleDbConnection to connect to the data source (the excel file). The file is is referred by a DataTable and each row in this DataTable is a sheet in Excel file. And thus, the row names are obtained easily.</p>
<p><span id="ctl00_ContentPlaceHolder1_lblDescription" style="color: DarkBlue;"> </span></p>
<pre><span style="color: #0000ff;">using </span><span style="color: #000000;">System.IO;</span>
<span style="color: #0000ff;">using </span><span style="color: #000000;">System.Data.OleDb;</span></pre>
<p><span id="ctl00_ContentPlaceHolder1_lblDescription" style="color: DarkBlue;"> </span></p>
<pre><span style="color: #0000ff;">protected </span><span style="color: #0000ff;">void </span><span style="color: #000000;">Page_Load(</span><span style="color: #0000ff;">object </span><span style="color: #000000;">sender</span>, <span style="color: #2b91af;">E<span style="color: #2b91af;">v</span>entArgs </span><span style="color: #000000;">e</span>)
<span style="color: #000000;">{</span>
    <span style="color: #000000;">GetExcelSheetNames</span>(<span style="color: #800000;">@"E:\\Book1.xls"</span><span style="color: #000000;">);</span>
<span style="color: #000000;">}</span></pre>
<p><span id="ctl00_ContentPlaceHolder1_lblDescription" style="color: DarkBlue;"> </span></p>
<pre><span style="color: #0000ff;">public </span><span style="color: #0000ff;">string</span>[] <span style="color: #000000;">GetExcelSheetNames(</span><span style="color: #0000ff;">string </span><span style="color: #000000;">excelFileName</span><span style="color: #000000;">)</span>
 <span style="color: #000000;">{</span>
      <span style="color: #008080;">OleDbConnection </span><span style="color: #000000;">con </span><span style="color: #000000;">=</span> <span style="color: #0000ff;">null</span><span style="color: #000000;">;</span>
      <span style="color: #008080;">DataTable </span><span style="color: #000000;">dt =</span> null<span style="color: #000000;">;</span>
      <span style="color: #008080;">String </span><span style="color: #000000;">conStr </span>= <span style="color: #800000;">"Provider=Microsoft.Jet.OLEDB.4.0;"</span> <span style="color: #000000;">+</span>
      <span style="color: #800000;">"Data Source="</span> <span style="color: #000000;">+ excelFileName +</span> <span style="color: #800000;">";Extended Properties=Excel 8.0;"</span><span style="color: #000000;">;</span>
      <span style="color: #000000;">con</span><span style="color: #000000;">=</span> <span style="color: #0000ff;">new </span><span style="color: #008080;">OleDbConnection</span><span style="color: #000000;">(conStr);</span>
      <span style="color: #000000;">con.Open();</span>
      <span style="color: #000000;">dt</span> <span style="color: #000000;">= con.</span><span style="color: #008080;">GetOleDbSchemaTable</span><span style="color: #000000;">(</span><span style="color: #008080;">OleDbSchemaGuid</span><span style="color: #000000;">.Tables, </span><span style="color: #0000ff;">null</span><span style="color: #000000;">);</span>

      <span style="color: #0000ff;">if</span> <span style="color: #000000;">(dt ==</span> <span style="color: #0000ff;">null</span><span style="color: #000000;">)</span>
     <span style="color: #000000;"> {</span>
          <span style="color: #0000ff;">return </span><span style="color: #0000ff;">null</span><span style="color: #000000;">;</span>
      <span style="color: #000000;">}</span>

      <span style="color: #008080;">String</span><span style="color: #000000;">[]</span> <span style="color: #000000;">excelSheetNames =</span> <span style="color: #0000ff;">new </span><span style="color: #008080;">String</span><span style="color: #000000;">[dt.Rows.Count];</span>
      int <span style="color: #000000;">i = 0;</span>

      <span style="color: #0000ff;">foreach </span><span style="color: #000000;">(</span><span style="color: #008080;">DataRow </span><span style="color: #000000;">row in dt.Rows)</span>
      <span style="color: #000000;">{
          excelSheetNames[i] = row[</span><span style="color: #800000;">"TABLE_NAME"</span><span style="color: #000000;">].ToString();</span>
          <span style="color: #000000;">i++;
      }</span>
      <span style="color: #0000ff;">return </span><span style="color: #000000;">excelSheetNames</span>;
 <span style="color: #000000;">}

Reference : <a href="http://source.witssquare.com/" target="_self">http://source.witssquare.com/</a></span></pre>
]]></content:encoded>
			<wfw:commentRss>http://source.witssquare.com/net/reading-excel-sheet-names-in-c-sharp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Get the Latest Session in SQL Server</title>
		<link>http://source.witssquare.com/sql-server/get-the-latest-session-in-sql-server/</link>
		<comments>http://source.witssquare.com/sql-server/get-the-latest-session-in-sql-server/#comments</comments>
		<pubDate>Mon, 09 Nov 2009 15:30:06 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Connect_time in sql server]]></category>
		<category><![CDATA[How to get latest sessions]]></category>
		<category><![CDATA[Last read and write in sql server]]></category>

		<guid isPermaLink="false">http://source.witssquare.com/?p=237</guid>
		<description><![CDATA[How to get the latest Session in SQL Server 2005 below,
SELECT Session_Id,Connect_Time,Auth_Scheme,Net_Packet_Size,Client_Net_Address FROM
sys.dm_exec_connections WHERE session_id=@@spid
Results :
Session_Id  Connect_Time            Auth_Scheme                              Net_Packet_Size Client_Net_Address
&#8212;&#8212;&#8212;&#8211; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;- &#8212;&#8212;&#8212;&#8212;&#8212; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-
53          2009-11-09 20:19:22.727 SQL                                      4096            &#60;local machine&#62;
Get the all details from this query,
SELECT * FROM sys.dm_exec_connections
The Details from all columns using like,
SELECT session_id,most_recent_session_id,connect_time,net_transport,protocol_type,
protocol_version,endpoint_id,encrypt_option,auth_scheme,node_affinity,
num_reads,num_writes,last_read,last_write,net_packet_size,
client_net_address,client_tcp_port,local_net_address,local_tcp_port,
connection_id,parent_connection_id,most_recent_sql_handle
FROM sys.dm_exec_connections
Reference : http://source.witssquare.com 
See also get solutinos
]]></description>
			<content:encoded><![CDATA[<p>How to get the latest Session in SQL Server 2005 below,</p>
<p><span style="color: #0000ff;">SELECT </span>Session_Id,Connect_Time,Auth_Scheme,Net_Packet_Size,Client_Net_Address <span style="color: #0000ff;">FROM</span><br />
<span style="color: #008000;">sys.dm_exec_connections</span> <span style="color: #0000ff;">WHERE </span>session_id=<span style="color: #ff00ff;">@@spid</span></p>
<p><span style="color: #ff0000;"><strong>Results :</strong></span></p>
<p>Session_Id  Connect_Time            Auth_Scheme                              Net_Packet_Size Client_Net_Address<br />
&#8212;&#8212;&#8212;&#8211; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;- &#8212;&#8212;&#8212;&#8212;&#8212; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
53          2009-11-09 20:19:22.727 SQL                                      4096            &lt;local machine&gt;</p>
<p>Get the all details from this query,</p>
<p><span style="color: #0000ff;">SELECT </span>* <span style="color: #0000ff;">FROM </span><span style="color: #008000;">sys.dm_exec_connections</span></p>
<p>The Details from all columns using like,</p>
<p><span style="color: #0000ff;">SELECT </span>session_id,most_recent_session_id,connect_time,net_transport,protocol_type,<br />
protocol_version,endpoint_id,encrypt_option,auth_scheme,node_affinity,<br />
num_reads,num_writes,last_read,last_write,net_packet_size,<br />
client_net_address,client_tcp_port,local_net_address,local_tcp_port,<br />
connection_id,parent_connection_id,most_recent_sql_handle<br />
<span style="color: #0000ff;">FROM </span><span style="color: #008000;">sys.dm_exec_connections</span></p>
<p>Reference : <a href="http://source.witssquare.com/" target="_self">http://source.witssquare.com </a></p>
<p><a href="http://blogs.msdn.com/sql_protocols/archive/2005/10/12/479871.aspx" target="_blank">See also get solutinos</a></p>
]]></content:encoded>
			<wfw:commentRss>http://source.witssquare.com/sql-server/get-the-latest-session-in-sql-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SQL SELECT TOP N equivalent in ORACLE and MySQL</title>
		<link>http://source.witssquare.com/sql-server/sql-select-top-n-equivalent-in-oracle-and-mysql/</link>
		<comments>http://source.witssquare.com/sql-server/sql-select-top-n-equivalent-in-oracle-and-mysql/#comments</comments>
		<pubDate>Thu, 05 Nov 2009 11:33:39 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[How to select top n value]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[oracle]]></category>
		<category><![CDATA[select top n value]]></category>
		<category><![CDATA[top]]></category>
		<category><![CDATA[top value]]></category>

		<guid isPermaLink="false">http://source.witssquare.com/?p=212</guid>
		<description><![CDATA[How to select top N value from SQL Server,Oracle and MySQL below,
SQL Server:
SELECT TOP 10 ProductName, Desc, EmailId
FROM Products

ORACLE:
 
SELECT ProductName, Desc, EmailId
 FROM Products
WHERE ROWNUM &#60;= 10
MySQL:
SELECT ProductName, Desc, EmailId
 FROM Products
LIMIT 10
Reference : http://source.witssquare.com
]]></description>
			<content:encoded><![CDATA[<p><span style="color: #ff6600;"><strong>How to select top N value from SQL Server,Oracle and MySQL below,</strong></span><br />
SQL Server:</p>
<div style="border: 1px solid black; padding: 5px; background-color: #FFFBCC;border-color:#E6DB55;"><span style="font-size: 10pt; color: #000000; font-family: Courier New;">SELECT TOP 10 ProductName, Desc, EmailId<br />
FROM Products<br />
</span></div>
<p>ORACLE:</p>
<p><span style="font-size: 10pt; color: #000000; font-family: Courier New;"> </span></p>
<div style="border: 1px solid black; padding: 5px; background-color: #FFFBCC;border-color:#E6DB55;"><span style="font-size: 10pt; color: #000000; font-family: Courier New;">SELECT </span><span style="font-size: 10pt; color: #000000; font-family: Courier New;">ProductName, Desc, EmailId</span><br />
<span style="font-size: 10pt; color: #000000; font-family: Courier New;"> FROM Products<br />
WHERE ROWNUM &lt;= 10</span></div>
<p>MySQL:</p>
<div style="border: 1px solid black; padding: 5px; background-color: #EEF6E8;border-color:#BED35B;"><span style="font-size: 10pt; color: #000000; font-family: Courier New;">SELECT </span><span style="font-size: 10pt; color: #000000; font-family: Courier New;">ProductName, Desc, EmailId</span><br />
<span style="font-size: 10pt; color: #000000; font-family: Courier New;"> FROM Products<br />
LIMIT 10</span></div>
<p>Reference : <a href="http://source.witssquare.com" target="_self">http://source.witssquare.com</a></p>
]]></content:encoded>
			<wfw:commentRss>http://source.witssquare.com/sql-server/sql-select-top-n-equivalent-in-oracle-and-mysql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Find System information using SQL Server</title>
		<link>http://source.witssquare.com/sql-server/find-system-information-using-sql-server/</link>
		<comments>http://source.witssquare.com/sql-server/find-system-information-using-sql-server/#comments</comments>
		<pubDate>Tue, 03 Nov 2009 08:03:56 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[find system info]]></category>
		<category><![CDATA[Find System information using SQL Server]]></category>
		<category><![CDATA[how to find system info]]></category>
		<category><![CDATA[information]]></category>
		<category><![CDATA[sys.dm_os_sys_info]]></category>
		<category><![CDATA[System information]]></category>

		<guid isPermaLink="false">http://source.witssquare.com/?p=205</guid>
		<description><![CDATA[How to find System information in SQl Server using Select Statement below,
SELECT * FROM sys.dm_os_sys_info
Get from the Particular fields above query,
SELECT CPU_Count,HyperThread_Ratio,Physical_Memory_In_Bytes / 1048576 as &#8216;Memory_In_MB&#8217;,Virtual_Memory_In_Bytes / 1048576 as &#8216;Virtual_Memory_In_MB&#8217;,
Max_Workers_Count,OS_Error_Mode,OS_Priority_Class FROM sys.dm_os_sys_info
Results :
CPU_Count   HyperThread_Ratio Memory_In_MB         Virtual_Memory_In_MB Max_Workers_Count OS_Error_Mode OS_Priority_Class
&#8212;&#8212;&#8212;&#8211; &#8212;&#8212;&#8212;&#8212;&#8212;&#8211; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; &#8212;&#8212;&#8212;&#8212;&#8212;&#8211; &#8212;&#8212;&#8212;&#8212;- &#8212;&#8212;&#8212;&#8212;&#8212;&#8211;
2           2                 1013                 2047                 256               5             32
Reference : http://source.witssquare.com
]]></description>
			<content:encoded><![CDATA[<p>How to find System information in SQl Server using Select Statement below,</p>
<p><span style="color: #0000ff;">SELECT </span>* <span style="color: #0000ff;">FROM </span><span style="color: #008000;">sys.dm_os_sys_info</span></p>
<p><span style="color: #008000;"><span style="color: #000000;">Get from the Particular fields above query,</span></span></p>
<p><span style="color: #0000ff;">SELECT </span>CPU_Count,HyperThread_Ratio,Physical_Memory_In_Bytes / 1048576 <span style="color: #0000ff;">as</span> <span style="color: #ff0000;">&#8216;Memory_In_MB&#8217;</span>,Virtual_Memory_In_Bytes / 1048576 <span style="color: #0000ff;">as</span><span style="color: #ff0000;"> &#8216;Virtual_Memory_In_MB&#8217;</span>,<br />
Max_Workers_Count,OS_Error_Mode,OS_Priority_Class <span style="color: #0000ff;">FROM </span><span style="color: #008000;">sys.dm_os_sys_info</span></p>
<p><span style="color: #000080;"><strong>Results :</strong></span></p>
<p>CPU_Count   HyperThread_Ratio Memory_In_MB         Virtual_Memory_In_MB Max_Workers_Count OS_Error_Mode OS_Priority_Class<br />
&#8212;&#8212;&#8212;&#8211; &#8212;&#8212;&#8212;&#8212;&#8212;&#8211; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; &#8212;&#8212;&#8212;&#8212;&#8212;&#8211; &#8212;&#8212;&#8212;&#8212;- &#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
2           2                 1013                 2047                 256               5             32</p>
<p><strong>Reference </strong>: <strong><a href="http://source.witssquare.com" target="_self">http://source.witssquare.com</a></strong></p>
]]></content:encoded>
			<wfw:commentRss>http://source.witssquare.com/sql-server/find-system-information-using-sql-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Get Server Username and Change Password in SQl Server</title>
		<link>http://source.witssquare.com/sql-server/get-server-username-and-change-password-in-sql-server/</link>
		<comments>http://source.witssquare.com/sql-server/get-server-username-and-change-password-in-sql-server/#comments</comments>
		<pubDate>Tue, 03 Nov 2009 07:49:37 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[change password]]></category>
		<category><![CDATA[get server username]]></category>
		<category><![CDATA[Get Server Username and Change Password in SQl Server]]></category>
		<category><![CDATA[How to change server password]]></category>
		<category><![CDATA[How to get server username]]></category>
		<category><![CDATA[sp_password]]></category>

		<guid isPermaLink="false">http://source.witssquare.com/?p=200</guid>
		<description><![CDATA[How to get current server username in sql server using select statement below,
&#8211;Get Current Server Username
SELECT SYSTEM_USER AS ServerUserName
Results :
ServerUserName
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;
sa
How to Change SQL Server Password,
&#8211;Change the Current Server Password
sp_password &#8216;CurrentPassword&#8217;,&#8216;NewPassword&#8217;


]]></description>
			<content:encoded><![CDATA[<p>How to get current server username in sql server using select statement below,</p>
<p><span style="color: #008000;">&#8211;Get Current Server Username</span><br />
<span style="color: #0000ff;">SELECT </span><span style="color: #ff00ff;">SYSTEM_USER</span> <span style="color: #0000ff;">AS</span> ServerUserName</p>
<p><span style="color: #003300;"><strong>Results :</strong></span></p>
<p>ServerUserName<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
sa</p>
<p>How to Change SQL Server Password,</p>
<p><span style="color: #008000;">&#8211;Change the Current Server Password</span><br />
<span style="color: #800000;">sp_password</span><span style="color: #ff0000;"> &#8216;CurrentPassword&#8217;</span>,<span style="color: #ff0000;">&#8216;NewPassword&#8217;</span></p>
<p><span style="color: #ff0000;"><br />
</span></p>
]]></content:encoded>
			<wfw:commentRss>http://source.witssquare.com/sql-server/get-server-username-and-change-password-in-sql-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Get Server Property in Product Level for SQL Server</title>
		<link>http://source.witssquare.com/sql-server/get-server-property-in-product-level-for-sql-server/</link>
		<comments>http://source.witssquare.com/sql-server/get-server-property-in-product-level-for-sql-server/#comments</comments>
		<pubDate>Tue, 03 Nov 2009 07:42:31 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Get Server Property in Product Level for SQL Server]]></category>
		<category><![CDATA[how to get server property]]></category>

		<guid isPermaLink="false">http://source.witssquare.com/?p=196</guid>
		<description><![CDATA[How to get the Server Property in SQL Server using select statement below,
&#8211;Check service pack level.
SELECT ServerProperty(&#8216;ProductLevel&#8217;) As Property

Reference : http://source.witssquare.com
]]></description>
			<content:encoded><![CDATA[<p>How to get the Server Property in SQL Server using select statement below,</p>
<p><span style="color: #008000;">&#8211;Check service pack level.</span><br />
<span style="color: #0000ff;">SELECT </span><span style="color: #ff00ff;">ServerProperty</span>(<span style="color: #ff0000;">&#8216;ProductLevel&#8217;</span>) <span style="color: #0000ff;">As </span>Property</p>
<p><img class="aligncenter size-full wp-image-197" title="GetServerProperty" src="http://source.witssquare.com/wp-content/uploads/2009/11/GetServerProperty.bmp" alt="GetServerProperty" /></p>
<p>Reference : <a href="http://source.witssquare.com" target="_self">http://source.witssquare.com</a></p>
]]></content:encoded>
			<wfw:commentRss>http://source.witssquare.com/sql-server/get-server-property-in-product-level-for-sql-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Get Current Server Name in SQL Server</title>
		<link>http://source.witssquare.com/sql-server/get-current-server-name-in-sql-server/</link>
		<comments>http://source.witssquare.com/sql-server/get-current-server-name-in-sql-server/#comments</comments>
		<pubDate>Tue, 03 Nov 2009 06:51:01 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[get @@Servername in sql server]]></category>
		<category><![CDATA[Get current Server name]]></category>
		<category><![CDATA[Get Current Server Name in SQL Server]]></category>
		<category><![CDATA[How to get Current servername in sql server]]></category>
		<category><![CDATA[Servername in sql server]]></category>

		<guid isPermaLink="false">http://source.witssquare.com/?p=190</guid>
		<description><![CDATA[How to Get Current Server Name ,using select statement in below,
&#8211;Get Current Server Name
SELECT @@ServerName AS CurrentServerName

Reference : http://source.witssquare.com
]]></description>
			<content:encoded><![CDATA[<p>How to Get Current Server Name ,using select statement in below,</p>
<p><span style="color: #008000;">&#8211;Get Current Server Name</span><br />
<span style="color: #0000ff;">SELECT </span><span style="color: #ff00ff;">@@ServerName</span> <span style="color: #0000ff;">AS <span style="color: #000000;">Current</span></span><span style="color: #000000;">ServerName</span></p>
<p style="text-align: center;"><img class="size-full wp-image-191 aligncenter" title="GetServerName" src="http://source.witssquare.com/wp-content/uploads/2009/11/GetServerName.bmp" alt="GetServerName" width="426" height="282" /></p>
<p>Reference : <a href="http://source.witssquare.com" target="_self">http://source.witssquare.com</a></p>
]]></content:encoded>
			<wfw:commentRss>http://source.witssquare.com/sql-server/get-current-server-name-in-sql-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Get Current Database Name in SQL Server</title>
		<link>http://source.witssquare.com/sql-server/get-current-database-name-in-sql-server/</link>
		<comments>http://source.witssquare.com/sql-server/get-current-database-name-in-sql-server/#comments</comments>
		<pubDate>Tue, 03 Nov 2009 06:37:14 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Get Database]]></category>
		<category><![CDATA[Get database name]]></category>
		<category><![CDATA[get DB_Name]]></category>
		<category><![CDATA[How to get current Database name]]></category>

		<guid isPermaLink="false">http://source.witssquare.com/?p=179</guid>
		<description><![CDATA[How to get current Database name in SQL Server, using select statement in below,
&#8211;Get Current Database Name
SELECT DB_NAME() AS DataBaseName

Reference : http://source.witssquare.com
]]></description>
			<content:encoded><![CDATA[<p>How to get current Database name in SQL Server, using select statement in below,</p>
<p><span style="color: #008000;">&#8211;Get Current Database Name</span><br />
<span style="color: #0000ff;">SELECT</span> <span style="color: #ff00ff;">DB_NAME<span style="color: #888888;">()</span> </span><span style="color: #0000ff;">AS</span> DataBaseName</p>
<p style="text-align: center;"><img class="size-full wp-image-186 aligncenter" title="GetDBName" src="http://source.witssquare.com/wp-content/uploads/2009/11/GetDBName3.bmp" alt="GetDBName" width="424" height="299" /></p>
<p>Reference :<a href="http://source.witssquare.com" target="_self"> http://source.witssquare.com</a></p>
]]></content:encoded>
			<wfw:commentRss>http://source.witssquare.com/sql-server/get-current-database-name-in-sql-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Merge the .NET DataTables</title>
		<link>http://source.witssquare.com/net/how-to-merge-the-net-datatables/</link>
		<comments>http://source.witssquare.com/net/how-to-merge-the-net-datatables/#comments</comments>
		<pubDate>Mon, 02 Nov 2009 12:09:42 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[GridView]]></category>
		<category><![CDATA[How to Merge the .NET DataTables]]></category>
		<category><![CDATA[Merge DataTables]]></category>
		<category><![CDATA[merge the two data tables]]></category>

		<guid isPermaLink="false">http://source.witssquare.com/?p=170</guid>
		<description><![CDATA[DataSet ds = new DataSet();
DataTable dt1 = new DataTable();
DataTable dt2 = new DataTable();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
dt1.Columns.Add(&#8220;ID&#8221;, Type.GetType(&#8220;System.Int32&#8243;));
dt1.Columns.Add(&#8220;Name&#8221;, Type.GetType(&#8220;System.String&#8221;));
dt1.Rows.Add(new object[] { 1, &#8220;Tommy1&#8243; });
dt1.Rows.Add(new object[] { 2, &#8220;Tommy2&#8243; });
dt1.Rows.Add(new object[] { 3, &#8220;Tommy3&#8243; });
ds.Tables.Add(dt1);
dt2.Columns.Add(&#8220;ID&#8221;, Type.GetType(&#8220;System.Int32&#8243;));
dt2.Columns.Add(&#8220;Name&#8221;, Type.GetType(&#8220;System.String&#8221;));
dt2.Rows.Add(new object[] { 4, &#8220;asdf4&#8243; });
dt2.Rows.Add(new object[] { 5, &#8220;asdf5&#8243; });
dt2.Rows.Add(new object[] { 6, &#8220;asdf6&#8243; });
ds.Tables.Add(dt2);
dt1.Merge(dt2, true, MissingSchemaAction.Ignore);
GridView1.DataSource [...]]]></description>
			<content:encoded><![CDATA[<p><span style="color: #008080;">DataSet </span>ds = <span style="color: #0000ff;">new </span><span style="color: #008080;">DataSet</span>();</p>
<p><span style="color: #008080;">DataTable </span>dt1 = <span style="color: #0000ff;">new </span><span style="color: #008080;">DataTable</span>();</p>
<p><span style="color: #008080;">DataTable </span>dt2 = <span style="color: #0000ff;">new </span><span style="color: #008080;">DataTable</span>();</p>
<p><span style="color: #0000ff;">protected </span><span style="color: #0000ff;">void </span>Page_Load(<span style="color: #0000ff;">object </span>sender, <span style="color: #008080;">EventArgs </span>e)<br />
{<br />
<span style="color: #0000ff;">if </span>(!IsPostBack)<br />
{<br />
dt1.Columns.Add(<span style="color: #800000;">&#8220;ID&#8221;</span>, <span style="color: #008080;">Type</span>.GetType(<span style="color: #800000;">&#8220;System.Int32&#8243;</span>));<br />
dt1.Columns.Add(<span style="color: #800000;">&#8220;Name&#8221;</span>, <span style="color: #008080;">Type</span>.GetType(<span style="color: #800000;">&#8220;System.String&#8221;</span>));<br />
dt1.Rows.Add(<span style="color: #0000ff;">new </span><span style="color: #0000ff;">object</span>[] { 1, <span style="color: #800000;">&#8220;Tommy1&#8243; </span>});<br />
dt1.Rows.Add(<span style="color: #0000ff;">new </span><span style="color: #0000ff;">object</span>[] { 2, <span style="color: #800000;">&#8220;Tommy2&#8243;</span> });<br />
dt1.Rows.Add(<span style="color: #0000ff;">new </span><span style="color: #0000ff;">object</span>[] { 3,<span style="color: #800000;"> &#8220;Tommy3&#8243;</span> });<br />
ds.Tables.Add(dt1);</p>
<p>dt2.Columns.Add(<span style="color: #800000;">&#8220;ID&#8221;</span>, Type.GetType(<span style="color: #800000;">&#8220;System.Int32&#8243;</span>));<br />
dt2.Columns.Add(<span style="color: #800000;">&#8220;Name&#8221;</span>, Type.GetType(<span style="color: #800000;">&#8220;System.String&#8221;</span>));<br />
dt2.Rows.Add(<span style="color: #0000ff;">new </span><span style="color: #0000ff;">object</span>[] { 4, <span style="color: #800000;">&#8220;asdf4&#8243;</span> });<br />
dt2.Rows.Add(<span style="color: #0000ff;">new </span><span style="color: #0000ff;">object</span>[] { 5, <span style="color: #800000;">&#8220;asdf5&#8243;</span> });<br />
dt2.Rows.Add(<span style="color: #0000ff;">new </span><span style="color: #0000ff;">object</span>[] { 6, <span style="color: #800000;">&#8220;asdf6&#8243;</span> });<br />
ds.Tables.Add(dt2);</p>
<p>dt1.Merge(dt2, <span style="color: #0000ff;">true</span>, <span style="color: #008080;">MissingSchemaAction</span>.Ignore);</p>
<p>GridView1.DataSource = dt1;<br />
GridView1.DataBind();</p>
<p><span style="color: #008000;">//Use other way of work use Below Union DataTable Function<br />
//GridView1.DataSource = Union(dt1, dt2);<br />
//GridView1.DataBind();</span><br />
}<br />
}</p>
<p><span style="color: #008000;">//Union DataTable Function</span></p>
<p><span style="color: #0000ff;">public </span><span style="color: #0000ff;">static </span><span style="color: #008080;">DataTable </span>Union(<span style="color: #008080;">DataTable </span>First, <span style="color: #008080;">DataTable </span>Second)<br />
{<br />
<span style="color: #008000;">//Result table</span><br />
<span style="color: #008080;">DataTable </span>table = new <span style="color: #008080;">DataTable</span>(<span style="color: #800000;">&#8220;Union&#8221;</span>);<br />
<span style="color: #008000;">//Build new columns</span><br />
<span style="color: #008080;">DataColumn</span>[] newcolumns = new <span style="color: #008080;">DataColumn</span>[First.Columns.Count];<br />
<span style="color: #0000ff;">for</span> (<span style="color: #0000ff;">int </span>i = 0; i &lt; First.Columns.Count; i++)<br />
{<br />
newcolumns[i] = <span style="color: #0000ff;">new </span>DataColumn(First.Columns[i].ColumnName, First.Columns[i].DataType);<br />
}<br />
table.Columns.AddRange(newcolumns);<br />
table.BeginLoadData();<br />
<span style="color: #0000ff;">foreach </span>(<span style="color: #008080;">DataRow </span>row<span style="color: #0000ff;"> in</span> First.Rows)<br />
{<br />
table.LoadDataRow(row.ItemArray, <span style="color: #0000ff;">true</span>);<br />
}<br />
<span style="color: #0000ff;">foreach </span>(<span style="color: #008080;">DataRow </span>row <span style="color: #0000ff;">in</span> Second.Rows)<br />
{<br />
table.LoadDataRow(row.ItemArray, <span style="color: #0000ff;">true</span>);<br />
}<br />
table.EndLoadData();</p>
<p><span style="color: #0000ff;">return </span>table;</p>
<p>}</p>
<div id="_mcePaste" style="overflow: hidden; position: absolute; left: -10000px; top: 1024px; width: 1px; height: 1px;"><!--[if gte mso 9]><xml> <w:WordDocument> <w:View>Normal</w:View> <w:Zoom>0</w:Zoom> <w:PunctuationKerning /> <w:ValidateAgainstSchemas /> <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid> <w:IgnoreMixedContent>false</w:IgnoreMixedContent> <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText> <w:Compatibility> <w:BreakWrappedTables /> <w:SnapToGridInCell /> <w:WrapTextWithPunct /> <w:UseAsianBreakRules /> <w:DontGrowAutofit /> </w:Compatibility> <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel> </w:WordDocument> </xml><![endif]--><!--[if gte mso 9]><xml> <w:LatentStyles DefLockedState="false" LatentStyleCount="156"> </w:LatentStyles> </xml><![endif]--><!--[if !mso]><span class="mceItemObject"   classid="clsid:38481807-CA0E-42D2-BF39-B33AF135CC4D" id=ieooui></span> <mce:style><!  st1\:*{behavior:url(#ieooui) } --> <!--[endif]--><!--  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal 	{mso-style-parent:""; 	margin:0in; 	margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:12.0pt; 	font-family:"Times New Roman"; 	mso-fareast-font-family:"Times New Roman";} @page Section1 	{size:8.5in 11.0in; 	margin:1.0in 1.25in 1.0in 1.25in; 	mso-header-margin:.5in; 	mso-footer-margin:.5in; 	mso-paper-source:0;} div.Section1 	{page:Section1;} --><!--[if gte mso 10]> <mce:style><!   /* Style Definitions */  table.MsoNormalTable 	{mso-style-name:"Table Normal"; 	mso-tstyle-rowband-size:0; 	mso-tstyle-colband-size:0; 	mso-style-noshow:yes; 	mso-style-parent:""; 	mso-padding-alt:0in 5.4pt 0in 5.4pt; 	mso-para-margin:0in; 	mso-para-margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:10.0pt; 	font-family:"Times New Roman"; 	mso-ansi-language:#0400; 	mso-fareast-language:#0400; 	mso-bidi-language:#0400;} --> <!--[endif]--></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">protected</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> <span style="color: blue;">void</span> Page_Load(<span style="color: blue;">object</span> sender, <span style="color: #2b91af;">EventArgs</span> e)</span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> {</span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> <span style="color: blue;">if</span> (!IsPostBack)</span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> {</span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> dt1.Columns.Add(<span style="color: #a31515;">&#8220;ID&#8221;</span>, <span style="color: #2b91af;">Type</span>.GetType(<span style="color: #a31515;">&#8220;System.Int32&#8243;</span>));</span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> dt1.Columns.Add(<span style="color: #a31515;">&#8220;Name&#8221;</span>, <span style="color: #2b91af;">Type</span>.GetType(<span style="color: #a31515;">&#8220;System.String&#8221;</span>));</span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> dt1.Rows.Add(<span style="color: blue;">new</span> <span style="color: blue;">object</span>[] { 1, <span style="color: #a31515;">&#8220;Tommy1&#8243;</span> });</span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> dt1.Rows.Add(<span style="color: blue;">new</span> <span style="color: blue;">object</span>[] { 2, <span style="color: #a31515;">&#8220;Tommy2&#8243;</span> });</span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> dt1.Rows.Add(<span style="color: blue;">new</span> <span style="color: blue;">object</span>[] { 3, <span style="color: #a31515;">&#8220;Tommy3&#8243;</span> });</span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> ds.Tables.Add(dt1);</span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> </span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> Session[<span style="color: #a31515;">"ss"</span>] = dt1;</span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> </span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> dt2.Columns.Add(<span style="color: #a31515;">&#8220;ID&#8221;</span>, <span style="color: #2b91af;">Type</span>.GetType(<span style="color: #a31515;">&#8220;System.Int32&#8243;</span>));</span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> dt2.Columns.Add(<span style="color: #a31515;">&#8220;Name&#8221;</span>, <span style="color: #2b91af;">Type</span>.GetType(<span style="color: #a31515;">&#8220;System.String&#8221;</span>));</span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> dt2.Rows.Add(<span style="color: blue;">new</span> <span style="color: blue;">object</span>[] { 4, <span style="color: #a31515;">&#8220;asdf4&#8243;</span> });</span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> dt2.Rows.Add(<span style="color: blue;">new</span> <span style="color: blue;">object</span>[] { 5, <span style="color: #a31515;">&#8220;asdf5&#8243;</span> });</span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> dt2.Rows.Add(<span style="color: blue;">new</span> <span style="color: blue;">object</span>[] { 6, <span style="color: #a31515;">&#8220;asdf6&#8243;</span> });</span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> ds.Tables.Add(dt2);</span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> </span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> <span style="color: green;">//HTbl.Add(1, &#8220;A&#8221;);</span></span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> <span style="color: green;">//HTbl.Add(2, &#8220;B&#8221;);</span></span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> <span style="color: green;">//HTbl.Add(3, &#8220;C&#8221;);</span></span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: green;"> </span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> dt1.Merge(dt2, <span style="color: blue;">true</span>, <span style="color: #2b91af;">MissingSchemaAction</span>.Ignore);</span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> </span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> GridView1.DataSource = dt1;</span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> GridView1.DataBind();</span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> </span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> </span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> <span style="color: green;">//GridView1.DataSource = Union(dt1, dt2);</span></span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> <span style="color: green;">//GridView1.DataBind();</span></span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> }</span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> }</span></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://source.witssquare.com/net/how-to-merge-the-net-datatables/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Calculate the Median Value in SQL Server</title>
		<link>http://source.witssquare.com/sql-server/calculate-the-median-value-in-sql-server/</link>
		<comments>http://source.witssquare.com/sql-server/calculate-the-median-value-in-sql-server/#comments</comments>
		<pubDate>Fri, 30 Oct 2009 09:12:31 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[calculate median]]></category>
		<category><![CDATA[Calculate the Median Value in SQL Server]]></category>
		<category><![CDATA[find median]]></category>
		<category><![CDATA[Median]]></category>
		<category><![CDATA[Median Value]]></category>
		<category><![CDATA[Median value in sql server]]></category>

		<guid isPermaLink="false">http://source.witssquare.com/?p=165</guid>
		<description><![CDATA[use testbase
create table tblMedian(val int)
Insert into tblMedian (val) Values (10)
Insert into tblMedian (val) Values (30)
Insert into tblMedian (val) Values (60)
Insert into tblMedian (val) Values (100)
Insert into tblMedian (val) Values (110)
Insert into tblMedian (val) Values (150)
Insert into tblMedian (val) Values (170)
Insert into tblMedian (val) Values (1000)
select * from tblMedian ORDER BY val ASC
Via I :
DECLARE @M1 [...]]]></description>
			<content:encoded><![CDATA[<p><span style="color: #0000ff;">use </span>testbase</p>
<p><span style="color: #0000ff;">create </span><span style="color: #0000ff;">table </span>tblMedian(val <span style="color: #0000ff;">int</span>)<br />
<span style="color: #0000ff;">Insert </span><span style="color: #0000ff;">into </span>tblMedian (val) <span style="color: #0000ff;">Values </span>(10)<br />
<span style="color: #0000ff;">Insert </span><span style="color: #0000ff;">into </span>tblMedian (val) <span style="color: #0000ff;">Values </span>(30)<br />
<span style="color: #0000ff;">Insert </span><span style="color: #0000ff;">into </span>tblMedian (val) <span style="color: #0000ff;">Values </span>(60)<br />
<span style="color: #0000ff;">Insert </span><span style="color: #0000ff;"><span style="color: #0000ff;">into</span> </span>tblMedian (val) <span style="color: #0000ff;">Values </span>(100)<br />
<span style="color: #0000ff;">Insert </span><span style="color: #0000ff;">into </span>tblMedian (val) <span style="color: #0000ff;">Values </span>(110)<br />
<span style="color: #0000ff;">Insert into</span> tblMedian (val) <span style="color: #0000ff;">Values </span>(150)<br />
<span style="color: #0000ff;">Insert into</span> tblMedian (val) <span style="color: #0000ff;">Values </span>(170)<br />
<span style="color: #0000ff;">Insert into</span> tblMedian (val) <span style="color: #0000ff;">Values </span>(1000)</p>
<p><span style="color: #0000ff;">select</span> * <span style="color: #0000ff;">from </span>tblMedian <span style="color: #0000ff;">ORDER BY</span> val <span style="color: #0000ff;">ASC</span></p>
<p><span style="color: #ff6600;"><strong>Via I :</strong></span><br />
<span style="color: #0000ff;">DECLARE </span>@M1 <span style="color: #0000ff;">int</span>, @M2 <span style="color: #0000ff;">int</span><br />
<span style="color: #0000ff;">SELECT TOP</span> 50 <span style="color: #0000ff;">PERCENT </span>@M1 = val<span style="color: #0000ff;"> FROM</span> tblMedian  <span style="color: #0000ff;">ORDER BY</span> val<span style="color: #0000ff;"> ASC</span><br />
<span style="color: #0000ff;">SELECT TOP</span> 50 <span style="color: #0000ff;">PERCENT </span>@M2 = val <span style="color: #0000ff;">FROM</span> tblMedian  <span style="color: #0000ff;">ORDER BY</span> val <span style="color: #0000ff;">DESC</span><br />
<span style="color: #0000ff;">SELECT </span>(@M1+@M2)/2.0</p>
<p><strong>Results :</strong><br />
MedianValue<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
105.000000</p>
<p><span style="color: #ff6600;"><strong>Via II :</strong></span><br />
<span style="color: #0000ff;">SELECT </span>(<br />
(<span style="color: #0000ff;">SELECT </span><span style="color: #0000ff;">TOP </span>1 val <span style="color: #0000ff;">FROM</span><br />
(<span style="color: #0000ff;">SELECT <span style="color: #0000ff;"> </span></span><span style="color: #0000ff;">TOP </span>50 <span style="color: #0000ff;">PERCENT </span>val <span style="color: #0000ff;">FROM </span>tblMedian <span style="color: #0000ff;">WHERE </span>val <span style="color: #808080;">IS NOT NULL</span> <span style="color: #0000ff;">ORDER BY</span> val) <span style="color: #0000ff;">AS</span> A <span style="color: #0000ff;">ORDER BY</span> val <span style="color: #0000ff;">DESC</span>)<br />
+<br />
(<span style="color: #0000ff;">SELECT TOP</span> 1 val <span style="color: #0000ff;">FROM</span><br />
(<span style="color: #0000ff;">SELECT  TOP</span> 50 <span style="color: #0000ff;">PERCENT </span>val <span style="color: #0000ff;">FROM</span> tblMedian <span style="color: #0000ff;">WHERE </span>val <span style="color: #808080;">IS NOT NULL</span> <span style="color: #0000ff;">ORDER BY</span> val <span style="color: #0000ff;">DESC</span>) <span style="color: #0000ff;">AS</span> A <span style="color: #0000ff;">ORDER BY</span> val <span style="color: #0000ff;">ASC</span>)<br />
) / 2 as MedianValue</p>
<p><span style="color: #808000;"><strong>Results:</strong></span><br />
MedianValue<br />
&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
105</p>
]]></content:encoded>
			<wfw:commentRss>http://source.witssquare.com/sql-server/calculate-the-median-value-in-sql-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ContextSwitchDeadLock erorr while debugging in C#.NET</title>
		<link>http://source.witssquare.com/net/contextswitchdeadlock-erorr-while-debugging-in-c-net/</link>
		<comments>http://source.witssquare.com/net/contextswitchdeadlock-erorr-while-debugging-in-c-net/#comments</comments>
		<pubDate>Fri, 30 Oct 2009 08:54:40 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[ContextSwitchDeadLock]]></category>
		<category><![CDATA[ContextSwitchDeadLock erorr in c#.net]]></category>
		<category><![CDATA[ContextSwitchDeadLock erorr while debugging in C#.NET]]></category>
		<category><![CDATA[ContextSwitchDeadLock MDA under the debugger]]></category>
		<category><![CDATA[ContextSwitchDeadlock was detected]]></category>
		<category><![CDATA[error in c#.net]]></category>

		<guid isPermaLink="false">http://source.witssquare.com/?p=160</guid>
		<description><![CDATA[While debugging a managed code batch process today I ran into VS throwing a &#8216;ContextSwitchDeadlock MDA&#8217; error. The debugger was attached to several long running process&#8217;s and towards the end of the cycle VS was reporting this issue. As Mike Stall reports it seems to be caused by the thread running the managed code I [...]]]></description>
			<content:encoded><![CDATA[<p>While debugging a managed code batch process today I ran into VS throwing a &#8216;ContextSwitchDeadlock MDA&#8217; error. The debugger was attached to several long running process&#8217;s and towards the end of the cycle VS was reporting this issue. As <a href="http://blogs.msdn.com/jmstall/archive/2005/11/11/ContextSwitchDeadLock.aspx">Mike Stall reports</a> it seems to be caused by the thread running the managed code I am debugging timing out but the unmanaged thread seeing not seeing it as dead. Why the managed code I am running times out in the debugger thread I am not clear about. It seems like that the debugger has a fixed response to all break points that starts at execution time, as each step I am debugging goes off to the database, waits a while and then comes back, it eats into this time. Eventually the debugger thread times out and the ContextSwitchDeadlock error occurs. You can&#8217;t stop this kind of error (although I do wonder if the time out value on the debugger thread could be adjusted) but you can disable the warning.</p>
<p>Two tips I <a href="http://social.msdn.microsoft.com/forums/en-US/vsdebug/thread/ed6db6c8-3cdc-4a23-ab0a-2f9b32470d35/" target="_blank">extracted from this thread</a> is,</p>
<ul>
<li>
<div>First you don&#8217;t already have it (Debug &#8211; Exceptions) obtain the debug exceptions window (right click tool bar &#8211; customize &#8211; debug and drag exceptions into the debug menu).</div>
</li>
<li>
<div>Select from Debug &#8211; Exceptions &#8211; Managed Debugging Assistants and disable ContextSwitchDeadlock.</div>
</li>
</ul>
<p>I had no luck with trying to disable this via reg keys and config files but that is suggested in the MDA help files.</p>
<p><a href="http://blogs.msdn.com/lifenglu/archive/2007/05/09/contextswitchdeadlock-mda-and-com.aspx" target="_blank">Also Reffer </a></p>
]]></content:encoded>
			<wfw:commentRss>http://source.witssquare.com/net/contextswitchdeadlock-erorr-while-debugging-in-c-net/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>New security features in SQL Server 2005</title>
		<link>http://source.witssquare.com/net/new-security-features-in-sql-server-2005/</link>
		<comments>http://source.witssquare.com/net/new-security-features-in-sql-server-2005/#comments</comments>
		<pubDate>Fri, 30 Oct 2009 06:11:14 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[advantages]]></category>
		<category><![CDATA[features of sql server]]></category>
		<category><![CDATA[Sceurity Features in sql server 2005]]></category>
		<category><![CDATA[security features]]></category>

		<guid isPermaLink="false">http://source.witssquare.com/?p=158</guid>
		<description><![CDATA[SQL Server 2005 adds new security features, not only to make SQL Server more secure, but to make security more understandable and easier to administer. Some of these features will permit programmers to develop database applications while running with the exact privileges that they need. This is known as &#8220;the principle of least privilege.&#8221; No [...]]]></description>
			<content:encoded><![CDATA[<p>SQL Server 2005 adds new security features, not only to make SQL Server more secure, but to make security more understandable and easier to administer. Some of these features will permit programmers to develop database applications while running with the exact privileges that they need. This is known as &#8220;the principle of least privilege.&#8221; No longer does every programmer need to run as database administrator or &#8220;sa.&#8221; The major new features include the following.</p>
<ul>
<li>Security for .NET executable code &#8212; Administration and execution of .NET code is managed through a combination of SQL Server permissions, Windows permissions, and .NET code security. What the code can or cannot do inside and outside SQL Server is defined with three distinct levels.</li>
<li>Password policies for SQL server users &#8212; If you run SQL Server 2005 on a Windows 2003 Server, SQL users can go by the same policies as integrated security users.</li>
<li>Mapping SQL Server users to Windows credentials &#8212; SQL Server users can use Windows credentials when accessing external resources like files and network shares.</li>
<li>Separation of users and schemas &#8212; SQL Server 2005 schemas are first-class objects that can be owned by a user, role, group, or application roles. The capability to define synonyms makes this easier to administer.</li>
<li>Granting permissions &#8212; No longer do users or logins have to be in special roles to have certain permissions; they are all grantable with the GRANT, DENY, and REVOKE verbs.</li>
<li>New security on SQL Server metadata &#8212; New metadata views are not directly updatable, and users can only list metadata about objects to which they have permission. There is also a new grantable VIEW DEFINITION permission.</li>
<li>Execution context for procedural code &#8212; You can set the execution context for stored procedures and user-defined functions. You can also use the EXECUTE AS syntax to change the current user.</li>
<li>Support of certificates and encryption keys &#8212; SQL Server 2005 can manage certificates and encryption keys for use with Service Broker, with Web Services SSL, for code authentication, and for new data encryption functions.</li>
</ul>
<p>Some of the new security features are outside the scope of this book, and some were still in development at the time of this writing. But we&#8217;ll look at most of them in detail in this chapter. Running non-T-SQL code in a secure and reliable fashion inside SQL Server is a new concept, and we will spend a lot of this chapter examining how SQL Server&#8217;s new security features combine with the latest .NET runtime to make this possible. We include a review of how security currently works in SQL Server in general to establish a baseline of knowledge.</p>
<p>We will start by looking at a change in the general policy of how SQL Server is configured. Though having optional features turned off by default is technically not a feature as such, most will consider it an important step forward in securing SQL Server.</p>
]]></content:encoded>
			<wfw:commentRss>http://source.witssquare.com/net/new-security-features-in-sql-server-2005/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
