Trim not removing spaces in SQL

When I Was importing text file to SQL server, sometime it include spaces with data as well. And That space it not remove by using Trim function.These spaces appear as white spaces to our eyes but this is not the truth. When I check it with ASCII(char) it shows char 10- Line Feed(LF), 13 – Carriage Return(CR), 160 –nbsp. So the solution is to replace these characters with white spaces (CHAR(32)) and then apply the TRIM function to it. Below is the screipt for it:

SELECT LTRIM(RTRIM(REPLACE(REPLACE(REPLACE([ColumnName], CHAR(10), CHAR(32)),
                                        CHAR(13), CHAR(32)), CHAR(160),
                                CHAR(32)))) AS [ColumnName] 
FROM [TableName]

Update:: include tab – CHAR(9)

SELECT LTRIM(RTRIM(REPLACE(REPLACE(REPLACE(REPLACE([ColumnName], CHAR(10), CHAR(32))
                                  ,CHAR(13), CHAR(32))
                                  ,CHAR(160), CHAR(32))
                                  ,CHAR(9),CHAR(32))))
FROM [TableName]

Thanks
[ad#inpost]

Disable Cut, Copy and Paste function for textbox using jQuery

All you need is to bind cut, copy and paste function to Textbox and stop the current action. See below code.

$(document).ready(function(){
  $('#txtInput').live("cut copy paste",function(e) {
      e.preventDefault();
  });
});

You can also use bind function to bind these events. Read more about bind() method here.

$(document).ready(function(){
  $('#txtInput').bind("cut copy paste",function(e) {
      e.preventDefault();
  });
});

Thanks

How to check if jQuery library and plugin is loaded?

jQuery library

To check if jQuery library is loaded, use the following JavaScript code :
Method 1:

Method 2:

jQuery Plugin

Here is how to check if some jQuery plugin is loaded or not:

For example, let’s assume that my plugin depends on jQuery Validation plugin. To check if validation plugin is loaded I would do the following: