DECLARE @MyString VARCHAR(1000) --Control character DECLARE @Tab VARCHAR(2) DECLARE @LineFeed VARCHAR(2) DECLARE @CarriageReturn VARCHAR(2) DECLARE @SearchPattern VARCHAR(10) SET @Tab = CHAR(9) SET @LineFeed = CHAR(10) SET @CarriageReturn = CHAR(13) --Search for any single of more chars not with specified range SET @SearchPattern = '%[^ ' + @Tab + @LineFeed + @CarriageReturn + ']%' SET @MyString = CHAR(10) + ' ' + CHAR(10)+ CHAR(9) + 'My name is ' + CHAR(10) + ' babu ' + CHAR(10) + ' ' + CHAR(10) + CHAR(10) + ' ' + CHAR(10) SELECT LEN(@MyString) AS TotalLength SELECT @MyString AS MyString SELECT LEN( RTRIM( LTRIM( SUBSTRING( @MyString, PATINDEX(@SearchPattern, @MyString), LEN(@MyString) - PATINDEX(@SearchPattern, @MyString) - PATINDEX(@SearchPattern, REVERSE(@MyString)) + 2 ) ) ) ) AS AfterTrimedLength SELECT RTRIM( LTRIM( SUBSTRING( @MyString, PATINDEX(@SearchPattern, @MyString), LEN(@MyString) - PATINDEX(@SearchPattern, @MyString) - PATINDEX(@SearchPattern, REVERSE(@MyString)) + 2 ) ) ) AS AfterTrimed
Monday, September 26, 2011
Trim Leading Or Trailing Control Characters
Tuesday, September 13, 2011
Auto center pop up window
function PopupCenter() { var width = 600; var height = 480; var top = (screen.height / 2) - (height / 2); var left = (screen.width / 2) - (width / 2); var parametar = 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=' + width + ', height=' + height + ', top=' + top + ', left=' + left; var url = 'Default.aspx' var windowName = 'Default'; var targetWin = window.open(url, windowName, parametar); targetWin.focus(); return false; }Page with query string
function PopupCenter(Name, Age) { var width = 600; var height = 480; var top = (screen.height / 2) - (height / 2); var left = (screen.width / 2) - (width / 2); var parametar = 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=' + width + ', height=' + height + ', top=' + top + ', left=' + left; var url = 'Default.aspx?Name=' + Name + '&Age=' + Age; var windowName = 'Default'; var targetWin = window.open(url, windowName, parametar); targetWin.focus(); return false; }References
www.javascripter.net
msdn
htmlgoodies
Subscribe to:
Posts (Atom)