C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !






Trim Leading Characters using SQL functions


Posted Date: 24 Apr 2008    Resource Type: Code Snippets    Category: String Manipulations

Posted By: @@@ Hyderabadi Biryani @@@       Member Level: Diamond
Rating:     Points: 4



The code sample is a snippet that trims the leading characters in the input string.

For example, if the input is " hi " (please ignore quotes), and we choose to remove leading spaces, the output will be "hi ".

Trimming, generally, is a popular string manipulation function that helps remove unnecessary leading and trailing characters. This function removes the leading spaces alone.



CREATE FUNCTION [dbo].[fn_Trim_leading_characters] ( @Input VARCHAR(50), @LeadingCharacter CHAR(1) )
RETURNS VARCHAR(50)
AS
BEGIN
RETURN REPLACE(LTRIM(REPLACE(@Input, ISNULL(@LeadingCharacter, '0'), ' ')),
' ', ISNULL(@LeadingCharacter, '0'))
END
GO



One other example could be to remove leading 'a' characters from "aabc", the output now is "bc".




Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Trimming characters  .  Trim leading characters  .  String manipulation  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: spliting string
Previous Resource: Read contents of file into single string variable
Return to Discussion Resource Index
Post New Resource
Category: String Manipulations


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

it support

Contact Us    Privacy Policy    Terms Of Use