<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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: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>Comments on: SQL SERVER &#8211; Repeate String N Times Using String Function REPLICATE</title>
	<atom:link href="http://blog.sqlauthority.com/2007/06/25/sql-server-repeate-string-n-times-using-string-function-replicate/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sqlauthority.com/2007/06/25/sql-server-repeate-string-n-times-using-string-function-replicate/</link>
	<description>Personal Notes of Pinal Dave</description>
	<lastBuildDate>Fri, 10 Feb 2012 02:12:04 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: ramkoti</title>
		<link>http://blog.sqlauthority.com/2007/06/25/sql-server-repeate-string-n-times-using-string-function-replicate/#comment-89055</link>
		<dc:creator><![CDATA[ramkoti]]></dc:creator>
		<pubDate>Thu, 23 Sep 2010 05:00:26 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/06/25/sql-server-repeate-string-n-times-using-string-function-replicate/#comment-89055</guid>
		<description><![CDATA[Hi Madhivanan,

SELECT REPLICATE( &#039; http:://www.SQLAuthority.com&#039;  , 100) 

when Results to Grid, this is replicating 100 times.

when Results to Text, not replicating 100 times. Can u give me the reason.]]></description>
		<content:encoded><![CDATA[<p>Hi Madhivanan,</p>
<p>SELECT REPLICATE( &#8216; http:://www.SQLAuthority.com&#8217;  , 100) </p>
<p>when Results to Grid, this is replicating 100 times.</p>
<p>when Results to Text, not replicating 100 times. Can u give me the reason.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nguyen Truong Thin</title>
		<link>http://blog.sqlauthority.com/2007/06/25/sql-server-repeate-string-n-times-using-string-function-replicate/#comment-64659</link>
		<dc:creator><![CDATA[Nguyen Truong Thin]]></dc:creator>
		<pubDate>Wed, 07 Apr 2010 07:17:14 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/06/25/sql-server-repeate-string-n-times-using-string-function-replicate/#comment-64659</guid>
		<description><![CDATA[Hi Sunil.P,

This is code:

DECLARE @TempTable AS TABLE
(
	MyString varchar(256)
)

DECLARE @idx int
SET @idx = 1

WHILE ( @idx &lt;= 100)
	BEGIN
		INSERT INTO @TempTable VALUES(&#039;http://www.SQLAuthority.com&#039;)
		SET @idx = @idx + 1
	END
	
SELECT * FROM @TempTable]]></description>
		<content:encoded><![CDATA[<p>Hi Sunil.P,</p>
<p>This is code:</p>
<p>DECLARE @TempTable AS TABLE<br />
(<br />
	MyString varchar(256)<br />
)</p>
<p>DECLARE @idx int<br />
SET @idx = 1</p>
<p>WHILE ( @idx &lt;= 100)<br />
	BEGIN<br />
		INSERT INTO @TempTable VALUES(&#039;<a href="http://www.SQLAuthority.com&#038;#039" rel="nofollow">http://www.SQLAuthority.com&#038;#039</a>;)<br />
		SET @idx = @idx + 1<br />
	END</p>
<p>SELECT * FROM @TempTable</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Madhivanan</title>
		<link>http://blog.sqlauthority.com/2007/06/25/sql-server-repeate-string-n-times-using-string-function-replicate/#comment-61251</link>
		<dc:creator><![CDATA[Madhivanan]]></dc:creator>
		<pubDate>Tue, 16 Feb 2010 13:26:51 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/06/25/sql-server-repeate-string-n-times-using-string-function-replicate/#comment-61251</guid>
		<description><![CDATA[Set the result mode to Text (Press Ctrl+T) and try this code



SELECT REPLICATE( &#039;http://www.SQLAuthority.com &#039;+ char(13) , 100 )]]></description>
		<content:encoded><![CDATA[<p>Set the result mode to Text (Press Ctrl+T) and try this code</p>
<p>SELECT REPLICATE( &#8216;<a href="http://www.SQLAuthority.com" rel="nofollow">http://www.SQLAuthority.com</a> &#8216;+ char(13) , 100 )</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rahul Bhargava</title>
		<link>http://blog.sqlauthority.com/2007/06/25/sql-server-repeate-string-n-times-using-string-function-replicate/#comment-58796</link>
		<dc:creator><![CDATA[Rahul Bhargava]]></dc:creator>
		<pubDate>Fri, 18 Dec 2009 11:12:43 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/06/25/sql-server-repeate-string-n-times-using-string-function-replicate/#comment-58796</guid>
		<description><![CDATA[Hi Ani,
Logic behind that sorting as per my view  is that when sorting starts in characters like 12 and 4 in this case sql server compares first character of both which is 1 and 4 in this situation 1 is smaller then 4 so it keeps record 12 before 4.
But after concatenating 0&#039;s like 04 and 12 now sql server will start comparing both the characters and first it will get 0 and 1 in this case 0 is &lt; 1  and then it puts 04 first and then 12.(Like C language&#039;s string comparison function)

Thanks 
Rahul Bhargava]]></description>
		<content:encoded><![CDATA[<p>Hi Ani,<br />
Logic behind that sorting as per my view  is that when sorting starts in characters like 12 and 4 in this case sql server compares first character of both which is 1 and 4 in this situation 1 is smaller then 4 so it keeps record 12 before 4.<br />
But after concatenating 0&#8242;s like 04 and 12 now sql server will start comparing both the characters and first it will get 0 and 1 in this case 0 is &lt; 1  and then it puts 04 first and then 12.(Like C language&#039;s string comparison function)</p>
<p>Thanks<br />
Rahul Bhargava</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ani</title>
		<link>http://blog.sqlauthority.com/2007/06/25/sql-server-repeate-string-n-times-using-string-function-replicate/#comment-57864</link>
		<dc:creator><![CDATA[Ani]]></dc:creator>
		<pubDate>Tue, 24 Nov 2009 13:35:30 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/06/25/sql-server-repeate-string-n-times-using-string-function-replicate/#comment-57864</guid>
		<description><![CDATA[Hey Viji 

It was really a gud one but the logic is not clear . Can you please explain .

The replicate function gives the result 
000001
000004
009876
000xyz
000abc
000020
0aeiou
000067
000006
000012
but how does it orders it .

Plzzzzz explain]]></description>
		<content:encoded><![CDATA[<p>Hey Viji </p>
<p>It was really a gud one but the logic is not clear . Can you please explain .</p>
<p>The replicate function gives the result<br />
000001<br />
000004<br />
009876<br />
000xyz<br />
000abc<br />
000020<br />
0aeiou<br />
000067<br />
000006<br />
000012<br />
but how does it orders it .</p>
<p>Plzzzzz explain</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Viji</title>
		<link>http://blog.sqlauthority.com/2007/06/25/sql-server-repeate-string-n-times-using-string-function-replicate/#comment-53938</link>
		<dc:creator><![CDATA[Viji]]></dc:creator>
		<pubDate>Wed, 22 Jul 2009 02:57:38 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/06/25/sql-server-repeate-string-n-times-using-string-function-replicate/#comment-53938</guid>
		<description><![CDATA[Hi,
 We can use replicate for other uses also.   For example if we want to sort a column which is having both numeric and varchar then,


create table #tmptbl
(
x varchar(10)
)
-- 
insert into #tmptbl values (&#039;1&#039;)
insert into #tmptbl values (&#039;4&#039;)
insert into #tmptbl values (&#039;9876&#039;)
insert into #tmptbl values (&#039;xyz&#039;)
insert into #tmptbl values (&#039;abc&#039;)
insert into #tmptbl values (&#039;20&#039;)
insert into #tmptbl values (&#039;aeiou&#039;)
insert into #tmptbl values (&#039;67&#039;)
insert into #tmptbl values (&#039;6&#039;)
insert into #tmptbl values (&#039;12&#039;)
-- 
select x
from #tmptbl
order by
case when isnumeric(x)=1 then replicate(&#039;0&#039;,10-len(x))+x else x end  

Thanks
Regards
Viji]]></description>
		<content:encoded><![CDATA[<p>Hi,<br />
 We can use replicate for other uses also.   For example if we want to sort a column which is having both numeric and varchar then,</p>
<p>create table #tmptbl<br />
(<br />
x varchar(10)<br />
)<br />
&#8211;<br />
insert into #tmptbl values (&#8217;1&#8242;)<br />
insert into #tmptbl values (&#8217;4&#8242;)<br />
insert into #tmptbl values (&#8217;9876&#8242;)<br />
insert into #tmptbl values (&#8216;xyz&#8217;)<br />
insert into #tmptbl values (&#8216;abc&#8217;)<br />
insert into #tmptbl values (&#8217;20&#8242;)<br />
insert into #tmptbl values (&#8216;aeiou&#8217;)<br />
insert into #tmptbl values (&#8217;67&#8242;)<br />
insert into #tmptbl values (&#8217;6&#8242;)<br />
insert into #tmptbl values (&#8217;12&#8242;)<br />
&#8211;<br />
select x<br />
from #tmptbl<br />
order by<br />
case when isnumeric(x)=1 then replicate(&#8217;0&#8242;,10-len(x))+x else x end  </p>
<p>Thanks<br />
Regards<br />
Viji</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sunil.P</title>
		<link>http://blog.sqlauthority.com/2007/06/25/sql-server-repeate-string-n-times-using-string-function-replicate/#comment-47122</link>
		<dc:creator><![CDATA[Sunil.P]]></dc:creator>
		<pubDate>Mon, 23 Feb 2009 12:34:10 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/06/25/sql-server-repeate-string-n-times-using-string-function-replicate/#comment-47122</guid>
		<description><![CDATA[Hi Sir,

Your Article is very good. I got many tricks from this site.

(Why cant you open Course for SQL Server like NIIT course?)
 
I want to print one string in 100 times by row wise , how do we do?

SELECT REPLICATE( ‘ http://www.SQLAuthority.com ‘ , 100 )--&gt; This Prints in one row only.I want it print in 100 rows.

Please give the Simple Query to this.

Thanks and Regards
Sunil. P]]></description>
		<content:encoded><![CDATA[<p>Hi Sir,</p>
<p>Your Article is very good. I got many tricks from this site.</p>
<p>(Why cant you open Course for SQL Server like NIIT course?)</p>
<p>I want to print one string in 100 times by row wise , how do we do?</p>
<p>SELECT REPLICATE( ‘ <a href="http://www.SQLAuthority.com" rel="nofollow">http://www.SQLAuthority.com</a> ‘ , 100 )&#8211;&gt; This Prints in one row only.I want it print in 100 rows.</p>
<p>Please give the Simple Query to this.</p>
<p>Thanks and Regards<br />
Sunil. P</p>
]]></content:encoded>
	</item>
</channel>
</rss>

