<?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; UDF &#8211; Pad Ride Side of Number with 0 &#8211; Fixed Width Number Display</title>
	<atom:link href="http://blog.sqlauthority.com/2009/03/16/sql-server-udf-pad-ride-side-of-number-with-0-fixed-width-number-display/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sqlauthority.com/2009/03/16/sql-server-udf-pad-ride-side-of-number-with-0-fixed-width-number-display/</link>
	<description>Personal Notes of Pinal Dave</description>
	<lastBuildDate>Fri, 17 May 2013 15:26:57 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: SQL SERVER &#8211; Removing Leading Zeros From Column in Table &#171; SQL Server Journey with SQL Authority</title>
		<link>http://blog.sqlauthority.com/2009/03/16/sql-server-udf-pad-ride-side-of-number-with-0-fixed-width-number-display/#comment-376343</link>
		<dc:creator><![CDATA[SQL SERVER &#8211; Removing Leading Zeros From Column in Table &#171; SQL Server Journey with SQL Authority]]></dc:creator>
		<pubDate>Mon, 19 Nov 2012 01:31:20 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=3764#comment-376343</guid>
		<description><![CDATA[[...] SQL SERVER – UDF – Pad Ride Side of Number with 0 – Fixed Width Number Display [...]]]></description>
		<content:encoded><![CDATA[<p>[...] SQL SERVER – UDF – Pad Ride Side of Number with 0 – Fixed Width Number Display [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SQL SERVER &#8211; Preserve Leading Zero While Coping to Excel from SSMS &#171; SQL Server Journey with SQL Authority</title>
		<link>http://blog.sqlauthority.com/2009/03/16/sql-server-udf-pad-ride-side-of-number-with-0-fixed-width-number-display/#comment-354399</link>
		<dc:creator><![CDATA[SQL SERVER &#8211; Preserve Leading Zero While Coping to Excel from SSMS &#171; SQL Server Journey with SQL Authority]]></dc:creator>
		<pubDate>Sun, 30 Sep 2012 01:30:40 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=3764#comment-354399</guid>
		<description><![CDATA[[...] SQL SERVER – UDF – Pad Ride Side of Number with 0 – Fixed Width Number Display [...]]]></description>
		<content:encoded><![CDATA[<p>[...] SQL SERVER – UDF – Pad Ride Side of Number with 0 – Fixed Width Number Display [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Hiren Solanki</title>
		<link>http://blog.sqlauthority.com/2009/03/16/sql-server-udf-pad-ride-side-of-number-with-0-fixed-width-number-display/#comment-63166</link>
		<dc:creator><![CDATA[Hiren Solanki]]></dc:creator>
		<pubDate>Thu, 18 Mar 2010 10:42:34 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=3764#comment-63166</guid>
		<description><![CDATA[create function dbo.HirsPadding
(
 @size int,
 @input varchar(max)
)
returns varchar(max)
as
begin
	IF @size &lt; LEN(@input)
		RETURN RIGHT(@input,@size)
	return REPLICATE(0,@size-LEN(@input))+@input
end

select dbo.HirsPadding(10,&#039;12345&#039;)]]></description>
		<content:encoded><![CDATA[<p>create function dbo.HirsPadding<br />
(<br />
 @size int,<br />
 @input varchar(max)<br />
)<br />
returns varchar(max)<br />
as<br />
begin<br />
	IF @size &lt; LEN(@input)<br />
		RETURN RIGHT(@input,@size)<br />
	return REPLICATE(0,@size-LEN(@input))+@input<br />
end</p>
<p>select dbo.HirsPadding(10,&#039;12345&#039;)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brian Tkatch</title>
		<link>http://blog.sqlauthority.com/2009/03/16/sql-server-udf-pad-ride-side-of-number-with-0-fixed-width-number-display/#comment-61191</link>
		<dc:creator><![CDATA[Brian Tkatch]]></dc:creator>
		<pubDate>Mon, 15 Feb 2010 14:47:52 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=3764#comment-61191</guid>
		<description><![CDATA[@chrsitopher

This should be simple. First learn to create comma-separated values. Pinal has an article on that here: http://blog.sqlauthority.com/2009/11/25/sql-server-comma-separated-values-csv-from-table-column/]]></description>
		<content:encoded><![CDATA[<p>@chrsitopher</p>
<p>This should be simple. First learn to create comma-separated values. Pinal has an article on that here: <a href="http://blog.sqlauthority.com/2009/11/25/sql-server-comma-separated-values-csv-from-table-column/" rel="nofollow">http://blog.sqlauthority.com/2009/11/25/sql-server-comma-separated-values-csv-from-table-column/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Christopher</title>
		<link>http://blog.sqlauthority.com/2009/03/16/sql-server-udf-pad-ride-side-of-number-with-0-fixed-width-number-display/#comment-61143</link>
		<dc:creator><![CDATA[Christopher]]></dc:creator>
		<pubDate>Mon, 15 Feb 2010 06:04:41 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=3764#comment-61143</guid>
		<description><![CDATA[my requirement is

I am trying to figure out how to do looping in SQL.
I have table like below:

ID      System  Material
1       Floor   Wood
1       Floor   Carpet
1       Wall    Dry wall
1       Wall    Paper
2       Floor   Wood
2       Floor   Carpet

I &#039;d like to end up with results like:
ID      System  Material
1       Floor   Wood, Carpet
1       Wall    Dry Wall, Paper
2       Floor   Wood, Carpet

For this i need user defined function

Please give query]]></description>
		<content:encoded><![CDATA[<p>my requirement is</p>
<p>I am trying to figure out how to do looping in SQL.<br />
I have table like below:</p>
<p>ID      System  Material<br />
1       Floor   Wood<br />
1       Floor   Carpet<br />
1       Wall    Dry wall<br />
1       Wall    Paper<br />
2       Floor   Wood<br />
2       Floor   Carpet</p>
<p>I &#8216;d like to end up with results like:<br />
ID      System  Material<br />
1       Floor   Wood, Carpet<br />
1       Wall    Dry Wall, Paper<br />
2       Floor   Wood, Carpet</p>
<p>For this i need user defined function</p>
<p>Please give query</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rajesh.Dharmakkan</title>
		<link>http://blog.sqlauthority.com/2009/03/16/sql-server-udf-pad-ride-side-of-number-with-0-fixed-width-number-display/#comment-52199</link>
		<dc:creator><![CDATA[Rajesh.Dharmakkan]]></dc:creator>
		<pubDate>Fri, 22 May 2009 13:31:43 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=3764#comment-52199</guid>
		<description><![CDATA[Hi, 
This is my query for the same. 

use AdventureWorks
go 
alter procedure MYProc  @value1 bigint
as 
begin
declare @String1 varchar(10)
Declare @length bigint
Declare @TotalLength bigint
set @TotalLength = 10

set @length = @TotalLength - LEN(@value1)
set @String1 = REPLICATE (0,@length) + CONVERT (nvarchar(10),@value1)
print @String1
end 
go 

Exec Myproc 555]]></description>
		<content:encoded><![CDATA[<p>Hi,<br />
This is my query for the same. </p>
<p>use AdventureWorks<br />
go<br />
alter procedure MYProc  @value1 bigint<br />
as<br />
begin<br />
declare @String1 varchar(10)<br />
Declare @length bigint<br />
Declare @TotalLength bigint<br />
set @TotalLength = 10</p>
<p>set @length = @TotalLength &#8211; LEN(@value1)<br />
set @String1 = REPLICATE (0,@length) + CONVERT (nvarchar(10),@value1)<br />
print @String1<br />
end<br />
go </p>
<p>Exec Myproc 555</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SQL SERVER - Leading Zero to Number Journey to SQL Authority with Pinal Dave</title>
		<link>http://blog.sqlauthority.com/2009/03/16/sql-server-udf-pad-ride-side-of-number-with-0-fixed-width-number-display/#comment-51254</link>
		<dc:creator><![CDATA[SQL SERVER - Leading Zero to Number Journey to SQL Authority with Pinal Dave]]></dc:creator>
		<pubDate>Fri, 24 Apr 2009 02:02:07 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=3764#comment-51254</guid>
		<description><![CDATA[[...] SQL SERVER - UDF - Pad Ride Side of Number with 0 - Fixed Width Number Display [...]]]></description>
		<content:encoded><![CDATA[<p>[...] SQL SERVER &#8211; UDF &#8211; Pad Ride Side of Number with 0 &#8211; Fixed Width Number Display [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Madhivanan</title>
		<link>http://blog.sqlauthority.com/2009/03/16/sql-server-udf-pad-ride-side-of-number-with-0-fixed-width-number-display/#comment-50041</link>
		<dc:creator><![CDATA[Madhivanan]]></dc:creator>
		<pubDate>Thu, 26 Mar 2009 14:54:15 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=3764#comment-50041</guid>
		<description><![CDATA[Another method


declare @col varchar(100), @size int
set @col=363453344234
set @size=18
select replace(str(@col,@size),&#039; &#039;,&#039;0&#039;)]]></description>
		<content:encoded><![CDATA[<p>Another method</p>
<p>declare @col varchar(100), @size int<br />
set @col=363453344234<br />
set @size=18<br />
select replace(str(@col,@size),&#8217; &#8216;,&#8217;0&#8242;)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Simonn</title>
		<link>http://blog.sqlauthority.com/2009/03/16/sql-server-udf-pad-ride-side-of-number-with-0-fixed-width-number-display/#comment-49647</link>
		<dc:creator><![CDATA[Simonn]]></dc:creator>
		<pubDate>Sun, 22 Mar 2009 00:29:06 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=3764#comment-49647</guid>
		<description><![CDATA[Very interesting article, i have bookmarked your blog for future referrence. Best regards]]></description>
		<content:encoded><![CDATA[<p>Very interesting article, i have bookmarked your blog for future referrence. Best regards</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brian Tkatch</title>
		<link>http://blog.sqlauthority.com/2009/03/16/sql-server-udf-pad-ride-side-of-number-with-0-fixed-width-number-display/#comment-49217</link>
		<dc:creator><![CDATA[Brian Tkatch]]></dc:creator>
		<pubDate>Mon, 16 Mar 2009 19:08:08 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=3764#comment-49217</guid>
		<description><![CDATA[When calling the function with less than the length: (123,7,0)

Solution 1 truncates the value.
Solution 2 and 3 return the value itself.

I am surprised noone used STUFF():
CREATE FUNCTION dbo.a
(
 @Length		TINYINT,
 @Pad			VARCHAR(1),
 @Column_Value	INT
)
RETURNS VARCHAR(255)
AS
BEGIN
RETURN	STUFF
		(
		 REPLICATE(@Pad, @Length),
		 @Length - LEN(@Column_Value),
		 LEN(@Column_Value),
		 @Column_Value
		);
END
GO

select dbo.a(7, 0, 123);
drop function dbo.a]]></description>
		<content:encoded><![CDATA[<p>When calling the function with less than the length: (123,7,0)</p>
<p>Solution 1 truncates the value.<br />
Solution 2 and 3 return the value itself.</p>
<p>I am surprised noone used STUFF():<br />
CREATE FUNCTION dbo.a<br />
(<br />
 @Length		TINYINT,<br />
 @Pad			VARCHAR(1),<br />
 @Column_Value	INT<br />
)<br />
RETURNS VARCHAR(255)<br />
AS<br />
BEGIN<br />
RETURN	STUFF<br />
		(<br />
		 REPLICATE(@Pad, @Length),<br />
		 @Length &#8211; LEN(@Column_Value),<br />
		 LEN(@Column_Value),<br />
		 @Column_Value<br />
		);<br />
END<br />
GO</p>
<p>select dbo.a(7, 0, 123);<br />
drop function dbo.a</p>
]]></content:encoded>
	</item>
</channel>
</rss>
