<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Muhammad Awais Qaisrani</title>
	<atom:link href="http://qaisrani.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://qaisrani.wordpress.com</link>
	<description>.Net, Sql Server,Javascript</description>
	<lastBuildDate>Tue, 05 Jan 2010 09:02:27 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='qaisrani.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Muhammad Awais Qaisrani</title>
		<link>http://qaisrani.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://qaisrani.wordpress.com/osd.xml" title="Muhammad Awais Qaisrani" />
	<atom:link rel='hub' href='http://qaisrani.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Validate Checkbox list</title>
		<link>http://qaisrani.wordpress.com/2010/01/05/validate-checkbox-list/</link>
		<comments>http://qaisrani.wordpress.com/2010/01/05/validate-checkbox-list/#comments</comments>
		<pubDate>Tue, 05 Jan 2010 09:02:27 +0000</pubDate>
		<dc:creator>qaisrani</dc:creator>
				<category><![CDATA[Asp.net]]></category>
		<category><![CDATA[Javascript validation]]></category>
		<category><![CDATA[Validatio Controls]]></category>
		<category><![CDATA[Asp.net validation]]></category>
		<category><![CDATA[Custom validator]]></category>
		<category><![CDATA[Javascript Checkbox validation]]></category>

		<guid isPermaLink="false">http://qaisrani.wordpress.com/?p=24</guid>
		<description><![CDATA[To validate checkbox list in asp.net is very simple. I found the following code searching google. To validate checkbox list use the CustomValidator  control and set the ClientValidationFunction to the javascript function. Following is the javascript code. function ValidateCheckboxList(source, args) { var chkcbl_repeat_future= document.getElementById (&#8216;Id of the checkbox list&#8217;); var chkList= chkcbl_repeat_future.getElementsByTagName(&#8220;input&#8221;); for(var i=0;i { [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=qaisrani.wordpress.com&amp;blog=5389474&amp;post=24&amp;subd=qaisrani&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>To validate checkbox list in asp.net is very simple. I found the following code searching google.</p>
<p>To validate checkbox list use the CustomValidator  control and set the ClientValidationFunction to the<br />
javascript function. Following is the javascript code.<br />
function ValidateCheckboxList(source, args)<br />
{<br />
var chkcbl_repeat_future= document.getElementById (&#8216;Id of the checkbox list&#8217;);<br />
var chkList= chkcbl_repeat_future.getElementsByTagName(&#8220;input&#8221;);<br />
for(var i=0;i<br />
{<br />
if(chkList[i].checked)<br />
{<br />
args.IsValid = true;<br />
return;<br />
}<br />
}<br />
args.IsValid = false;<br />
}<br />
Here you can <a href="http://www.mediafire.com/?kzmghgmawmn" target="_blank">download</a> example code</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/qaisrani.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/qaisrani.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/qaisrani.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/qaisrani.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/qaisrani.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/qaisrani.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/qaisrani.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/qaisrani.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/qaisrani.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/qaisrani.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/qaisrani.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/qaisrani.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/qaisrani.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/qaisrani.wordpress.com/24/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=qaisrani.wordpress.com&amp;blog=5389474&amp;post=24&amp;subd=qaisrani&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://qaisrani.wordpress.com/2010/01/05/validate-checkbox-list/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c99a53b52feb2f7cb6311bd12b388676?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">qaisrani</media:title>
		</media:content>
	</item>
		<item>
		<title>Reset validation controls in asp.net</title>
		<link>http://qaisrani.wordpress.com/2009/10/30/reset-validation-controls-in-asp-net/</link>
		<comments>http://qaisrani.wordpress.com/2009/10/30/reset-validation-controls-in-asp-net/#comments</comments>
		<pubDate>Fri, 30 Oct 2009 09:24:26 +0000</pubDate>
		<dc:creator>qaisrani</dc:creator>
				<category><![CDATA[Asp.net]]></category>
		<category><![CDATA[Reset Controls]]></category>
		<category><![CDATA[Validatio Controls]]></category>
		<category><![CDATA[Validation Controls]]></category>

		<guid isPermaLink="false">http://qaisrani.wordpress.com/?p=21</guid>
		<description><![CDATA[When we use validation controls e.g required fieldvalidater in asp.net form and on the same form we are using reset button. Reset button reset the field but the validation controls are not reset. I found the following code is good for doing or resting the validation controls. Now our reset button will be server control [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=qaisrani.wordpress.com&amp;blog=5389474&amp;post=21&amp;subd=qaisrani&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>When we use validation controls e.g required fieldvalidater in asp.net form and on the same form we are using reset button. Reset button reset the field but the validation controls are not reset.</p>
<p>I found the following code is good for doing or resting the validation controls. Now our reset button will be</p>
<p>server control not html input type control.</p>
<p>&nbsp;</p>
<p>Dim val As IValidator</p>
<p>For Each val In Validators</p>
<p>val.IsValid = True</p>
<p>Next</p>
<p>This code will reset the all validation controls in the form. Now we will reset our other fields too.</p>
<p>&nbsp;</p>
<p>Here is code.</p>
<p>&nbsp;</p>
<p style="text-align:left;">Protected Sub btn_Reset_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn_Reset.Click</p>
<p style="text-align:left;">Dim val As IValidator</p>
<p style="text-align:left;">For Each val In Validators</p>
<p style="text-align:left;">val.IsValid = True</p>
<p style="text-align:left;">Next</p>
<p style="text-align:left;">ResetFormControlValues(Me)</p>
<p style="text-align:left;">End Sub</p>
<p style="text-align:left;">Private Sub ResetFormControlValues(ByVal parent As Control)</p>
<p style="text-align:left;">Me.txt_ConfirmTag.Text = &#8220;&#8221;</p>
<p style="text-align:left;">Me.txt_Description.Text = &#8220;&#8221;</p>
<p style="text-align:left;">Me.txt_RewardAmount.Text = &#8220;&#8221;</p>
<p style="text-align:left;">&#8216;For Each c As Control In parent.Controls</p>
<p style="text-align:left;">If c.Controls.Count &amp;gt; 0 Then</p>
<p style="text-align:left;">ResetFormControlValues(c)</p>
<p style="text-align:left;">Else</p>
<p style="text-align:left;">Select Case (c.GetType().ToString())</p>
<p style="text-align:left;">Case &#8220;System.Web.UI.WebControls.TextBox&#8221;</p>
<p style="text-align:left;">CType(c, TextBox).Text = &#8220;&#8221;</p>
<p style="text-align:left;">Case &#8220;System.Web.UI.WebControls.CheckBox&#8221;</p>
<p style="text-align:left;">CType(c, CheckBox).Checked = False</p>
<p style="text-align:left;">Case &#8220;System.Web.UI.WebControls.RadioButton&#8221;</p>
<p style="text-align:left;">CType(c, RadioButton).Checked = False</p>
<p style="text-align:left;">Case &#8220;System.Web.UI.WebControls.DropDownList&#8221;</p>
<p style="text-align:left;">CType(c, DropDownList).SelectedIndex = 0</p>
<p style="text-align:left;">End Select</p>
<p style="text-align:left;">End If</p>
<p style="text-align:left;">Next c</p>
<p style="text-align:left;">End Sub</p>
<p>&nbsp;</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/qaisrani.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/qaisrani.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/qaisrani.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/qaisrani.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/qaisrani.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/qaisrani.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/qaisrani.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/qaisrani.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/qaisrani.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/qaisrani.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/qaisrani.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/qaisrani.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/qaisrani.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/qaisrani.wordpress.com/21/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=qaisrani.wordpress.com&amp;blog=5389474&amp;post=21&amp;subd=qaisrani&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://qaisrani.wordpress.com/2009/10/30/reset-validation-controls-in-asp-net/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c99a53b52feb2f7cb6311bd12b388676?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">qaisrani</media:title>
		</media:content>
	</item>
		<item>
		<title>Generate Insert or Update Statements from table / SQL Server Row Script Creator</title>
		<link>http://qaisrani.wordpress.com/2009/10/20/generate-insert-or-update-statements-from-table-sql-server-row-script-creator/</link>
		<comments>http://qaisrani.wordpress.com/2009/10/20/generate-insert-or-update-statements-from-table-sql-server-row-script-creator/#comments</comments>
		<pubDate>Tue, 20 Oct 2009 09:55:10 +0000</pubDate>
		<dc:creator>qaisrani</dc:creator>
				<category><![CDATA[Sql Server]]></category>

		<guid isPermaLink="false">http://qaisrani.wordpress.com/?p=16</guid>
		<description><![CDATA[After googling I found some interesting code to generate insert and update statement for the specified table in sql server. This script will generate script to insert/update from a source table in one database to an  identical destination table in another database or server.  It can be run for inserts or updates,  and can be [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=qaisrani.wordpress.com&amp;blog=5389474&amp;post=16&amp;subd=qaisrani&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>After googling I found some interesting code to generate insert and update statement for the specified table in sql server.</p>
<p>This script will generate script to insert/update from a source table in one database to an  identical destination table in another database or server.  It can be run for inserts or updates,  and can be run for a single row in insert and update mode, or all rows in a table for insert mode.</p>
<p>declare @tab varchar(50)</p>
<p>,@pk1Val varChar(10)</p>
<p>,@pk1Name varChar(50)</p>
<p>,@qt char(1)</p>
<p>,@StatementType varChar(10)</p>
<p>set nocount on</p>
<p>/*</p>
<p>Instructions:</p>
<p>1) open script and connect to the source database</p>
<p>2) Change the  variable values to change the output options for the script below (@tab, @statementtype etc)</p>
<p>3) execute the script (best to use text output)</p>
<p>4) copy the script output into a script window, and run on the destination table.</p>
<p>@Tab = the name of the source table</p>
<p>@pk1Val = if selecting a single row or doing an update statement, the value of the primary key for that row</p>
<p>@pk1Name = if inserting a single row or doing an update statement, the name of the column for the primary key</p>
<p>@StatementType = either &#8216;INSERT&#8217; to create an insert statement or &#8216;UPDATE&#8217; for an Update statement</p>
<p>*/</p>
<p>select @tab = &#8216;mytable&#8217;, @pk1Val = &#8221;, @pk1Name = &#8221;, @StatementType = &#8216;UPDATE&#8217;</p>
<p>declare @tabName varchar(50)</p>
<p>, @colName varchar(50)</p>
<p>, @colType varchar(50)</p>
<p>, @collength varChar(50)</p>
<p>, @colOrder int</p>
<p>, @IsIdent char(1)</p>
<p>create table #output (Line varChar(4000), LineOrder int, rowNumber int)</p>
<p>create table #ColumnValues (ColName varChar(250), ColOrder int, RowNumber int, ColValue varchar(4000), colType varchar(50))</p>
<p>declare @out varchar(4000)</p>
<p>,@lineCounter int</p>
<p>,@ColValue varchar(4000)</p>
<p>,@sortCol varchar(50)</p>
<p>/* get the ordering column */</p>
<p>select @sortCol = sc.Name</p>
<p>from sysobjects so</p>
<p>inner join syscolumns sc</p>
<p>on so.id=  sc.id</p>
<p>inner join systypes st</p>
<p>on sc.xtype = st.xusertype</p>
<p>where so.Name = @tab</p>
<p>and ((sc.status = 0&#215;80) OR (ColOrder = 1 and not sc.status = 0&#215;80 ))</p>
<p>/* put in the repeating values based on the columns*/</p>
<p>declare objCurs CURSOR FOR</p>
<p>select so.name, sc.name, st.name, sc.length, Case when sc.status = 0&#215;80 then &#8216;Y&#8217; else &#8216;N&#8217; END as IsIdent, ColOrder</p>
<p>from sysobjects so</p>
<p>inner join syscolumns sc</p>
<p>on so.id=  sc.id</p>
<p>inner join systypes st</p>
<p>on sc.xtype = st.xusertype</p>
<p>where so.Name = @tab</p>
<p>DECLARE @counter int, @numCols int, @RowNumber int, @LastRowNumber int, @maxRowNumber int, @maxColOrder int</p>
<p>select @numCols = count(sc.id)</p>
<p>from sysobjects so</p>
<p>inner join syscolumns sc</p>
<p>on so.id=  sc.id</p>
<p>where so.Name = @tab</p>
<p>&#8211;select @numCols  &#8211;debug code</p>
<p>open objCurs</p>
<p>Fetch from objCurs</p>
<p>into @tabname, @colName, @colType, @colLength, @isIdent, @colOrder</p>
<p>while @@fetch_status = 0</p>
<p>begin</p>
<p>SET @counter = 0</p>
<p>/* get the value from the table */</p>
<p>if @IsIdent = &#8216;N&#8217;</p>
<p>BEGIN</p>
<p>&#8211;select @TabName,@ColName, @ColType, @ColLEngth, @isIdent, @ColOrder  &#8211;debug code</p>
<p>/* increase better type handling by inserting more case statments, handling different data types */</p>
<p>if datalength(@pk1Name) = 0 or datalength(@pk1Val) = 0</p>
<p>begin</p>
<p>/* getting all rows in the table */</p>
<p>exec (&#8216;insert into #ColumnValues (ColName, ColOrder, ColValue, ColType)</p>
<p>select  &#8221;&#8217; + @colName + &#8221;&#8217;, &#8216; + @ColOrder + &#8216;, Convert(nvarchar(4000),&#8217; + @colName + &#8216;) , &#8221;&#8217; + @colType + &#8221;&#8217; from &#8216; + @tabName + &#8216; order by &#8216; + @SortCol + &#8216; &#8216; +</p>
<p>&#8216; declare @counter int set @counter = 0 &#8216; +</p>
<p>&#8216; update #ColumnValues Set @Counter = RowNumber = @Counter + (&#8216; + @numCols + &#8216; * 10) where ColName = &#8221;&#8217; + @colName + &#8221;&#8221; )</p>
<p>end</p>
<p>else</p>
<p>begin</p>
<p>/* filtering by a pk val */</p>
<p>exec (&#8216;insert into #ColumnValues (RowNumber, ColName, ColORder, ColValue, ColType)</p>
<p>select 0, &#8221;&#8217; + @colName + &#8221;&#8217;, &#8216; + @ColOrder + &#8216;, Convert(nvarchar(4000),&#8217; + @colName + &#8216;) , &#8221;&#8217; + @colType + &#8221;&#8217; from &#8216; + @tabName +</p>
<p>&#8216; where &#8216; + @pk1Name + &#8216; = &#8216; + @pk1Val)</p>
<p>end</p>
<p>end /* if @isIdent = &#8216;n&#8217; */</p>
<p>Fetch Next from objCurs</p>
<p>into @tabname, @colName, @colType, @colLength, @IsIdent, @ColOrder</p>
<p>end</p>
<p>&#8211;select * from #ColumnValues &#8211;debug code</p>
<p>select @MaxRowNumber = Max(rowNumber) from #columnValues &#8211;keep highest row number so we know when we are finished</p>
<p>select @MaxColOrder = max(ColOrder) from #ColumnValues where RowNumber = @MaxRowNumber</p>
<p>/* next cursor for outputting the results from the retval table into the output table */</p>
<p>declare ColVal_Curs  cursor for</p>
<p>select ColName , ColOrder , RowNumber , ColValue , colType</p>
<p>from #ColumnValues</p>
<p>order by RowNumber, ColOrder</p>
<p>open ColVal_Curs</p>
<p>&#8211;set the last row number to the first in the table, so post loop checking works</p>
<p>select @lastRowNumber = min(rowNumber) from #ColumnValues</p>
<p>set @lineCounter = @LastRowNumber &#8211;initialise at the first row</p>
<p>fetch from ColVal_Curs into</p>
<p>@colName, @ColOrder, @RowNumber, @colValue, @ColType</p>
<p>while @@Fetch_status = 0</p>
<p>BEGIN /* cursor loop */</p>
<p>/* get the quote type to enclose the value from the column type */</p>
<p>select @qt = case @colType</p>
<p>when &#8216;nvarchar&#8217; then &#8221;&#8221;</p>
<p>when &#8216;nchar&#8217; then &#8221;&#8221;</p>
<p>when &#8216;DateTime&#8217; then &#8221;&#8221;</p>
<p>when &#8216;ntext&#8217; then &#8221;&#8221;</p>
<p>else &#8221;</p>
<p>end</p>
<p>&#8211;select @linecounter, @colName, @ColOrder, @RowNumber, @colValue, @ColType</p>
<p>if not @ColValue is null</p>
<p>if @rowNumber = @lineCounter</p>
<p>select @out = case @statementType</p>
<p>when  &#8216;UPDATE&#8217; THEN &#8216;Update &#8216; + @tab + &#8216; SET &#8216;</p>
<p>when  &#8216;INSERT&#8217; then &#8216;INSERT INTO &#8216; + @tab + &#8216; (&#8216;</p>
<p>end</p>
<p>begin</p>
<p>if @StatementType = &#8216;UPDATE&#8217;</p>
<p>BEGIN</p>
<p>select @Out = @out + @colName + &#8216; = &#8216; + @qt + COALESCE(@ColValue, &#8216;NULL&#8217;) + @qt + &#8216;,&#8217; &#8212; + @ColType</p>
<p>insert into #output (Line, LineOrder)</p>
<p>values (@out, @lineCounter)</p>
<p>end</p>
<p>if @statementType = &#8216;INSERT&#8217;</p>
<p>BEGIN</p>
<p>/* put comma in */</p>
<p>if @lineCounter &amp;gt; @RowNumber &#8211;not first line in set of values for row</p>
<p>select @out = @out + &#8216;,&#8217;</p>
<p>/*put in the name of the column */</p>
<p>insert into #output (Line, LineOrder)</p>
<p>values (@out + @colName</p>
<p>, @lineCounter)</p>
<p>if @lineCounter &amp;gt; @RowNumber &#8211;not first line in set of values for row</p>
<p>select @out = &#8216;,&#8217;</p>
<p>else</p>
<p>select @out = &#8221;</p>
<p>/* put in the value of the column */</p>
<p>insert into #output (Line, LineOrder)</p>
<p>values (@out + @qt + COALESCE(@ColValue, &#8216;NULL&#8217;) + @qt</p>
<p>, @lineCounter + 10 + @numCols)</p>
<p>END</p>
<p>end  /*not @ColValue is null */</p>
<p>select @lineCounter = @lineCounter + 1</p>
<p>set @out = &#8221;</p>
<p>/* get the next record*/</p>
<p>fetch from ColVal_Curs into</p>
<p>@colName, @ColOrder, @RowNumber, @colValue, @ColType</p>
<p>&#8211;select @ColOrder, @MaxColOrder, @@Fetch_Status  &#8211;debug code</p>
<p>if (@rowNumber &amp;gt; @lastRowNumber) or (@RowNumber = @MaxRowNumber and @MaxColOrder = @ColOrder and @@FEtch_Status = -1)</p>
<p>BEGIN</p>
<p>/* this bit of processing is done whenever the set of columsn in a row changes to the next row of the original table*/</p>
<p>/* ie we are building a record to insert, and the PK changes because we are at the next record */</p>
<p>/* remove the last comma from the last line */</p>
<p>declare @lastLine int</p>
<p>if @statementType = &#8216;UPDATE&#8217;</p>
<p>begin</p>
<p>/*remove last comma*/</p>
<p>update #output</p>
<p>set Line = left(Line,datalength(Line)-1)</p>
<p>where lineOrder = @LineCounter</p>
<p>/* insert a &#8216;where&#8217; clause */</p>
<p>insert into #output (line, LineOrder)</p>
<p>select &#8216; WHERE &#8216; + @pk1Name + &#8216; = &#8216; + @pk1Val, Max(LineOrder) + 1 from #output</p>
<p>end</p>
<p>if @statementType = &#8216;INSERT&#8217;</p>
<p>BEGIN</p>
<p>/* put in a &#8216;values&#8217; statement between the column names and the column values */</p>
<p>insert into #output (Line, LineOrder)</p>
<p>values (&#8216;) VALUES (&#8216;, @LastRowNumber + @numCols + 5)</p>
<p>/* close off the lot */</p>
<p>insert into #output (line, lineorder)</p>
<p>select &#8216;)&#8217;, Max(LineOrder) + 1 from #output</p>
<p>END</p>
<p>set @lastRowNumber = @RowNumber</p>
<p>set @lineCounter = @RowNumber  /* reset linecounter for next set */</p>
<p>update #output</p>
<p>set RowNumber = @rowNumber</p>
<p>where RowNumber is null</p>
<p>End /* if rownumber &amp;gt; last row number */</p>
<p>end /* cursor loop */</p>
<p>close objCurs</p>
<p>deallocate objCurs</p>
<p>close ColVal_Curs</p>
<p>deallocate ColVal_Curs</p>
<p>/* the following is an extra loop over the original code to output the code as one statement per row */</p>
<p>create table #combineOutput (rowNumber int, line varchar(4000))</p>
<p>/* get the statements out from the list*/</p>
<p>declare @output varchar(8000), @codeLine varchar(4000), @thisRowNum int, @lastRowNum int</p>
<p>select @output = &#8221;</p>
<p>declare line_curs cursor for</p>
<p>select line, RowNumber  from #output order by RowNumber, lineorder</p>
<p>open line_curs</p>
<p>fetch from line_curs into @codeLine, @thisRowNum</p>
<p>select @lastRowNum = @thisRowNum</p>
<p>while @@fetch_status = 0</p>
<p>begin</p>
<p>if @thisROwNum &amp;gt; @lastRowNum</p>
<p>BEGIN</p>
<p>/* insert a row into the aggregate table if a new row number */</p>
<p>insert into #combineOutput (rowNumber, line) values (@rowNumber, @output)</p>
<p>set @output = &#8221;</p>
<p>END</p>
<p>select @output = @output + @codeLine + &#8216; &#8216;</p>
<p>select @lastRowNum = @thisRowNum</p>
<p>fetch from line_curs into @codeLine, @thisRowNum</p>
<p>end</p>
<p>/* the last row needs to be inserted */</p>
<p>insert into #combineOutput (rowNumber, line) values (@rowNumber, @output)</p>
<p>close line_curs</p>
<p>deallocate line_curs</p>
<p>select line as [Copy and paste code from below] from #combineOutput order by rowNumber</p>
<p>/*  bug tracking code &#8211; uncomment to diagnose problems</p>
<p>select distinct RowNumber from #ColumnValues order by 1</p>
<p>select * from #ColumnValues</p>
<p>order by RowNumber, ColOrder, ColName, ColValue</p>
<p>*/</p>
<p>drop table #output</p>
<p>drop table #combineOutput</p>
<p>drop table #ColumnValues</p>
<p>set nocount off</p>
<p>/*</p>
<p><a href="http://ifinity.com.au/">Bruce Chapman Aug 2006</a></p>
<p>*/</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/qaisrani.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/qaisrani.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/qaisrani.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/qaisrani.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/qaisrani.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/qaisrani.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/qaisrani.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/qaisrani.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/qaisrani.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/qaisrani.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/qaisrani.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/qaisrani.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/qaisrani.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/qaisrani.wordpress.com/16/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=qaisrani.wordpress.com&amp;blog=5389474&amp;post=16&amp;subd=qaisrani&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://qaisrani.wordpress.com/2009/10/20/generate-insert-or-update-statements-from-table-sql-server-row-script-creator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c99a53b52feb2f7cb6311bd12b388676?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">qaisrani</media:title>
		</media:content>
	</item>
		<item>
		<title>SQL SERVER &#8211; 2008 &#8211; Interview Questions and Answers</title>
		<link>http://qaisrani.wordpress.com/2009/04/06/sql-server-2008-interview-questions-and-answers/</link>
		<comments>http://qaisrani.wordpress.com/2009/04/06/sql-server-2008-interview-questions-and-answers/#comments</comments>
		<pubDate>Mon, 06 Apr 2009 12:05:29 +0000</pubDate>
		<dc:creator>qaisrani</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://qaisrani.wordpress.com/?p=12</guid>
		<description><![CDATA[SQL SERVER &#8211; 2008 &#8211; Interview Questions and Answers Interview is very important event for any person. A good interview leads to good career if candidate is willing to learn. I always enjoy interview questions and answers series. This is my very humble attempt to write SQL Server 2008 interview questions and answers. SQL Server [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=qaisrani.wordpress.com&amp;blog=5389474&amp;post=12&amp;subd=qaisrani&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>SQL SERVER &#8211; 2008 &#8211; Interview Questions and Answers</strong></p>
<p>Interview is very important event for any person. A good interview leads to good career if candidate is willing to learn. I always enjoy interview questions and answers series. This is my very humble attempt to write SQL Server 2008 interview questions and answers. SQL Server is very large subject and not everything is usually asked in interview. In interview what matters the most is <strong>conceptual knowledge</strong> and <strong>learning attitude</strong>.</p>
<p><a class="aligncenter" title="SQL SERVER - 2008 - Interview Questions and Answers" href="http://http://blog.sqlauthority.com/2008/09/20/sql-server-2008-interview-questions-and-answers-complete-list-download/" target="_blank">SQL SERVER &#8211; 2008 &#8211; Interview Questions and Answers</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/qaisrani.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/qaisrani.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/qaisrani.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/qaisrani.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/qaisrani.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/qaisrani.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/qaisrani.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/qaisrani.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/qaisrani.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/qaisrani.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/qaisrani.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/qaisrani.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/qaisrani.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/qaisrani.wordpress.com/12/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=qaisrani.wordpress.com&amp;blog=5389474&amp;post=12&amp;subd=qaisrani&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://qaisrani.wordpress.com/2009/04/06/sql-server-2008-interview-questions-and-answers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c99a53b52feb2f7cb6311bd12b388676?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">qaisrani</media:title>
		</media:content>
	</item>
		<item>
		<title>Insert list of values in sql server</title>
		<link>http://qaisrani.wordpress.com/2008/11/11/insert-list-of-values-in-sql-server/</link>
		<comments>http://qaisrani.wordpress.com/2008/11/11/insert-list-of-values-in-sql-server/#comments</comments>
		<pubDate>Tue, 11 Nov 2008 05:08:06 +0000</pubDate>
		<dc:creator>qaisrani</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[adding list in sql server]]></category>
		<category><![CDATA[insert list of values in sql server]]></category>
		<category><![CDATA[Sql Server]]></category>

		<guid isPermaLink="false">http://qaisrani.wordpress.com/?p=5</guid>
		<description><![CDATA[We can insert list of values in sql server database in single column. This list is comma separated. Here is store procedure doing this. Create PROCEDURE  States_InsertStateList @Siteid as int, @StrSateID as varchar(5000), @strTaxAmout as varchar(5000) AS BEGIN delete from Taxes where Site_ID=@Siteid Declare @Delimiter char(1) DECLARE @StateID Varchar(5000) DECLARE @TaxAmout Varchar(5000) set @Delimiter = [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=qaisrani.wordpress.com&amp;blog=5389474&amp;post=5&amp;subd=qaisrani&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>We can insert list of values in sql server database in single column. This list is comma separated. Here is store procedure doing this.</p>
<p>Create PROCEDURE  States_InsertStateList<br />
@Siteid as int,<br />
@StrSateID as varchar(5000),<br />
@strTaxAmout as varchar(5000)<br />
AS<br />
BEGIN<br />
delete from Taxes where Site_ID=@Siteid<br />
Declare @Delimiter char(1)<br />
DECLARE @StateID Varchar(5000)<br />
DECLARE @TaxAmout Varchar(5000)<br />
set @Delimiter = &#8216;,&#8217;<br />
declare @List TABLE (Item varchar(8000),Amount varchar(8000))<br />
WHILE CHARINDEX(@Delimiter,@StrSateID,0) &lt;&gt; 0<br />
BEGIN<br />
SELECT @StateID=RTRIM(LTRIM(SUBSTRING(@StrSateID,1,CHARINDEX(@Delimiter,@StrSateID,0)-1))),</p>
<p>@StrSateID=RTRIM(LTRIM(SUBSTRING(@StrSateID,CHARINDEX(@Delimiter,@StrSateID,0)+1,LEN(@StrSateID))))<br />
SELECT @TaxAmout=RTRIM(LTRIM(SUBSTRING(@strTaxAmout,1,CHARINDEX(@Delimiter,@strTaxAmout,0)-1))),</p>
<p>@strTaxAmout=RTRIM(LTRIM(SUBSTRING(@strTaxAmout,CHARINDEX(@Delimiter,@strTaxAmout,0)+1,LEN(@strTaxAmout))))<br />
IF LEN(@StateID) &gt; 0<br />
begin<br />
INSERT INTO @List SELECT @StateID,@TaxAmout<br />
end<br />
END<br />
IF LEN(@StrSateID) &gt; 0<br />
INSERT INTO @List SELECT @StrSateID,@strTaxAmout</p>
<p>insert into Taxes (State_ID,Amount,Site_ID)select Item,Amount,@Siteid from @list<br />
END</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/qaisrani.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/qaisrani.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/qaisrani.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/qaisrani.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/qaisrani.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/qaisrani.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/qaisrani.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/qaisrani.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/qaisrani.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/qaisrani.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/qaisrani.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/qaisrani.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/qaisrani.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/qaisrani.wordpress.com/5/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=qaisrani.wordpress.com&amp;blog=5389474&amp;post=5&amp;subd=qaisrani&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://qaisrani.wordpress.com/2008/11/11/insert-list-of-values-in-sql-server/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c99a53b52feb2f7cb6311bd12b388676?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">qaisrani</media:title>
		</media:content>
	</item>
		<item>
		<title>Drop Store Procedure in Sql Server</title>
		<link>http://qaisrani.wordpress.com/2008/11/03/hello-world/</link>
		<comments>http://qaisrani.wordpress.com/2008/11/03/hello-world/#comments</comments>
		<pubDate>Mon, 03 Nov 2008 08:04:09 +0000</pubDate>
		<dc:creator>qaisrani</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Sql Server]]></category>
		<category><![CDATA[Store procedure]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[To drop sql server store procedure use the following . USE [name of database] GO IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N&#8217;[dbo].[name of store procedure]&#8216;) AND type in (N&#8217;P', N&#8217;PC&#8217;)) DROP PROCEDURE [dbo].[name of store procedure]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=qaisrani.wordpress.com&amp;blog=5389474&amp;post=1&amp;subd=qaisrani&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>To drop sql server store procedure use the following .</p>
<p>USE [name of database]<br />
GO<br />
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N&#8217;[dbo].[name of store procedure]&#8216;) AND type in (N&#8217;P', N&#8217;PC&#8217;))<br />
DROP PROCEDURE [dbo].[name of store procedure]</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/qaisrani.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/qaisrani.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/qaisrani.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/qaisrani.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/qaisrani.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/qaisrani.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/qaisrani.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/qaisrani.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/qaisrani.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/qaisrani.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/qaisrani.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/qaisrani.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/qaisrani.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/qaisrani.wordpress.com/1/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=qaisrani.wordpress.com&amp;blog=5389474&amp;post=1&amp;subd=qaisrani&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://qaisrani.wordpress.com/2008/11/03/hello-world/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c99a53b52feb2f7cb6311bd12b388676?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">qaisrani</media:title>
		</media:content>
	</item>
	</channel>
</rss>
