Website Design United States, Website Design California, Website Designing United States, Website Designing California

PadLeft and PadRight - SQL

These functions are used to pad the left or right side of your text with spaces. This is useful when outputting fixed width data.

create function PadLeft (@value varchar(1024), @FieldLength int)
returns varchar(1024)
AS
BEGIN
declare @ret varchar(1024)
if @FieldLength > 0
set @ret = right(space(@FieldLength) + @value, @FieldLength)
else
set @ret = @value
return(@ret)
END

create function PadRight (@value varchar(1024), @FieldLength int)
returns varchar(1024)
AS
BEGIN
declare @ret varchar(1024)
if @FieldLength > 0
set @ret = left(@value + space(@FieldLength), @FieldLength)
else
set @ret = @value
return(@ret)
END


WEB DESIGN INDIA
42 B Malviya Nagar , New Delhi-110017

Skype: manmeetsi
Email: support.webdesignindia@gmail.com
Tel: 91-011-40502005, 9810067295

 















 


© 2008-2009 dotnet4all.com