Removing Spaces From An Nvarchar Column

Jul 20, 2005

This is a simple question, hopefully with a simple answer. I have
an nvarchar column of length 255. In one of the rows I have the
following sentance - 'See the brown ball bounce'. Is it possible to
use a command to remove all of the spaces in that sentance, so that
the sentance reads 'Seethebrownballbounce'? As you can see, I am not
just interested in getting rid of the trailing and leading spaces.


View 1 Replies


Removing White Spaces In A Varchar Column

Sep 15, 2005

I have a table . It has a nullable column called AccountNumber, whichis of varchar type. The AccountNumber is alpha-numeric. I want to takedata from this table and process it for my application. Before doingthat I would like to filter out duplicate AccountNumbers. I get most ofthe duplicates filtered out by using this query:select * from customerswhere AccountNumber NOT IN (select AccountNumber from customers whereAccountNumber <> '' group by AccountNumber having count(AccountNumber)[color=blue]> 1)[/color]But there are few duplicate entries where the actual AccountNumber issame, but there is a trailing space in first one, and hence thisduplicate records are not getting filtered out. e.g"abc123<white-space>" and "abc123" are considered two different entriesby above query.I ran a query like :update customers set AccountNumber = LTRIM(RTRIM(AccountNumber)But even after this query, the trailing space remains, and I am notable to filter out those entries.Am I missing anything here? Can somebody help me in making sure Ifilter out all duplicate entries ?Thanks,Rad

View 3 Replies View Related

Removing Spaces From A Text

Aug 31, 2006

Hi. In our database, we have a Social Security Number field. We've made application upgrades and we can no longer have the dashes ( - ) between the numbers. So, I ran this update on our database to remove all the dashes. it did remove all the dashes except it put spaces in its spot:

UPDATE DefendantCase SET SSN = REPLACE(SSN, '-','')

so, i tried this query and it does nothing.

UPDATE DefendantCase SET SSN = REPLACE(SSN, ' ','')

does anybody have any ideas? Thanks!

View 5 Replies View Related

Reportviewer Removing Spaces

Oct 17, 2007

Hi there,

I have a text box with the following expression:

="OEM Part Code" + " " + "Part Code" +" " + "Part Description"

As you can see, there is a lot of spaces in here. The reportviewer removes these spaces. so that it look like
OEM Part Code Part Code Part Description"

Instead of
OEM Part Code Part Code Part Description

Why is it doing this?
Can I stop it from doing this?


View 3 Replies View Related

Removing Spaces Between Words In Sql

Mar 20, 2007

I guess there is no built in functions to do this but I have a function that replaces anything that is not A-Z with a space and returns @data. What I additionally need the function to do is scrunch up @data (remove all blanks betwwen each word so that 'I ran very fast' would be 'Iranveryfast').

What I need help in doing is the "Scrunch" part. Is there a way I could move the @Data to something like @DataHold and inspect each character, if it is not a blank, move that character back to @Data?
This was pretty easy for me to do in C# with a while loop, but I do not know how to get it done in SQL Server 2005.

Thanks for any help!

View 4 Replies View Related

Removing Leading And Trainling Spaces

Dec 10, 2001

I loaded data into a CHAR fields from Legacy.
How to remove those leading spaces with in SQL server...?

View 1 Replies View Related

Removing Records With Spaces In Fields

Mar 26, 2008

How do i eliminate records which has spaces

i tried with

select * from table
where col1 !='' or
col1 is not null

which doesn't work.. any help.

View 1 Replies View Related

UPDATE - Removing Trailing Spaces

Jul 20, 2005

I have three columns, RecordID, FirstName, and LastName, but somehowthrough some program glitch, there is sometimes a trailing space inthe firstname and lastname columns, for example, a persons name couldbe entered as "John " "Smith" or "Bob " "Johnson "I know there is a RTRIM function in sql, but the problem I/m having ismaking an update line go through each row, and removing trailingspaces on those two columns. Any help will be greatly appreciated.Thanks in advance.

View 1 Replies View Related

Trailing Spaces In Nvarchar Columns

Nov 30, 2007

Hi All,

For ÄúnvarcharÄ? column if we pass the value as spaces, then it stores as space.


declare @path nvarchar(50)

set @path = ' '

select '=>' + @path + '<='

Is there any setting / configuration that will force it to automatically trim the spaces and store it as null?

Thanks in Advance,

View 1 Replies View Related

Removing Non-alpha Characters && Spaces Script...

Dec 6, 2006

Hi I am trying to strip out any non-alpha characters from a field.

i.e. Field = ABC"_IT8*$ should return: ABCIT8

I am writing a loop to do this for all values of a field. The script runs, but hangs....please could somebody advise on the code below...:

I run the script but it doesn't seem to finish. Can anybody see any issues with the code:

@MATCH_Supplier_name varchar(500),
@Counter numeric,
@Max numeric
-- @sqlstring varchar(500)

SET @Counter = 1

WHILE @Counter <@Max
SET @MATCH_Supplier_name = (SELECT Match_Supplier_Name FROM SUPPLIER_TABLE_TEST WHERE @Counter = DTect_Supplier_SRN)
SET @Index = LEN(@MATCH_Supplier_name)
WHILE @Index > = 1
SET @MATCH_Supplier_name = CASE
WHEN SUBSTRING(@MATCH_Supplier_name, @Index, 1) LIKE '[a-zA-Z]' TH EN SUBSTRING(@MATCH_Supplier_name, @Index, 1)
WHEN SUBSTRING(@MATCH_Supplier_name, @Index, 1) LIKE '[0-9]' THEN SUBSTRING(@MATCH_Supplier_name, @Index, 1)
END + @MATCH_Supplier_name
SET @Index = @Index - 1
--PRINT @MATCH_Supplier_name
SET @Counter = @Counter + 1

View 2 Replies View Related

T-SQL (SS2K8) :: RTRIM Not Removing Trailing Spaces?

Jul 14, 2014

I am loading a dimension using a distinct query.There are duplicates coming through and the only differnce is a trailing space on one of the columns.

RTRIM is not removing the space.

how i can fix it?

View 4 Replies View Related

Keeping Trailing Spaces On Function Returning Nvarchar(4000)

Mar 21, 2008

I'm trying desparately to write a PadRight function in SQL Server 2005. I seem to be failing miserably because the trailing spaces disappear when the data is returned. First of all, why does SQL Server think I want my string trimmed? And second, how do I overcome this? Code below:

Code Snippet
CREATE FUNCTION [dbo].[PadRight]

@sourceString NVARCHAR(4000),
@length INT,
@padCharacter NCHAR(1) = ' ',
@trimBeforePadding BIT = 1

DECLARE @returnStringLength AS INT, @toReturn AS NVARCHAR(4000)
SET @toReturn = LEFT(@sourceString, @length)

IF @trimBeforePadding = 1

SET @toReturn = RTRIM(LTRIM(@toReturn))
SET @returnStringLength = LEN(@toReturn)
IF @returnStringLength < @length

SET @toReturn = @toReturn + REPLICATE(@padCharacter, @length - @returnStringLength)
RETURN @toReturn

View 8 Replies View Related

Reporting Services :: How To Remove Blank Spaces After Removing Duplicated Records

Aug 18, 2015

I wanted to remove duplicate records from SSRS report. I set the "Hide Duplicates" to True. It is now working, But i am getting the space between the two records, which i want to get rid of. How to get rid of extra spaces between two records ( Please find the details below).

View 5 Replies View Related

Transact SQL :: Add Spaces To First Column So That Second Column Will Be Aligned

Sep 14, 2015

I want to add spaces (like space - len(col)) to first column so that second column will be aligned when exported to email (text).

DECLARE @ColumnSpaces TABLE (
 Col_1 VARCHAR(50),
 Col_2 VARCHAR(50)
INSERT INTO @ColumnSpaces VALUES ('AAA', '123')

View 6 Replies View Related

Getting Spaces In A Column

Mar 7, 2008

I have a single column value like this. I want to get the charindex value whereever it is a single space.

'6 REP5426 15936 022708 107/0000 33003301985 BAILEY AMY NICOL 11454 PP 25.00 000-00 00110080 A O '


View 5 Replies View Related

All Spaces In A CHAR(5) Column

Jan 31, 2005

i'm going nuts with this, i suppose i will crack it eventually, but i thought i'd ask around here, seems like all the smart SQL Server guys hang out here

(i'm an SQL guy, not an SQL Server guy)

how does one place 5 spaces into a CHAR(5) column?
create table testzeros
( id smallint not null primary key identity
, myfield char(5)
insert into testzeros (myfield) values (' 1')
insert into testzeros (myfield) values (' 11')
insert into testzeros (myfield) values (' 111')
insert into testzeros (myfield) values (' 1111')
insert into testzeros (myfield) values ('11111')
insert into testzeros (myfield) values (' ')

select id
, myfield
, len(myfield) as L
from testzerosno matter what i do, id=6 shows up with L=0, just like an empty string

i've even tried inserting 4 spaces and a non-blank character, which enters just fine, just as you would expect, but when i update the value and replace the non-blank character with a blank, all 5 spaces collapse back to an empty string

is there some kind of server setting like SET ALL_SPACE_EQUALS_EMPTY_YOU_IDIOT to OFF or something?

View 12 Replies View Related

Inserting A Value With Spaces Into A Column

Jun 17, 2008


I am fairly new to SQL I have started to administer a system which handles carrier information for a mail order system. The logic behind the system is quite simple there are 5 or so columns in a table the first column is the first part of the postcode i.e EX15, the other columns contain which delivery services and depot numbers are associated with that postcode. It works fine at the moment.

However now the main carrier has decided that they are now going to split these postcodes so for example EX15 1* goes to a different depot than EX15 2*

I cant seem to insert EX15 1 into the first column, I get the following error:

Attempt to store duplicate value in unique column. (-155)

Is this because of the space in 'EX15 1'? Because 'EX15' already exists in that column? In which case do I need to somehow tell SQL that there is a space there?

I hope this makes sense

Below is a snap of the table with the existing EX15 postcode data


Here is a snap of how I would like to set up another entry:

EX15 1...|NF/S93......|........1|34........|C.......|DEVO
EX15 1...|NF/SAT......|........1|34........|C.......|DEVO
EX15 1...|NF/930......|........1|34........|C.......|DEVO
EX15 1...|NF/AM.......|........1|34........|C.......|DEVO
EX15 1...|NF/ON.......|........1|34........|C.......|DEVO
EX15 1...|NF/48.......|........1|34........|C.......|DEVO
EX15 1...|NF/3D.......|........1|34........|C.......|DEVO


View 3 Replies View Related

Spaces In Column Names

Apr 6, 2006

Hi all,

Is it a bad practice to create column names with spaces. like [Last Modified On]?

If yes, y?

View 9 Replies View Related

How To Get Values From Column With Trailing Spaces

Jul 23, 2013

Performing security audit using command to retrieve data from Active Director about security groups and drop results into local tbl for analysis.

EXEC xp_cmdshell 'net group "AnalyticsDev" /domain'

Problem is the col created to store result is varchar(1000) and can hold 1-3 values (loginIDs) per row with lots of trailing/white space.

E.g. (EmpID101, EmpID250 EmpID10)

Is there a technique to extract the needed value (loginIDs) from col?

View 4 Replies View Related

Need Your Help To Remove Spaces In The Column Entries Using SQL

Oct 21, 2006

Hi all,I am new to these so plz never mind if this is is my problem :Table : moodyColumn : TitleNew column : NospaceI have data in "Title" column of many rows which are normal sentence.My requirment is to remove the "white space", +, | , ., / , ! @, $, %etc special characters and fill it by ( hyphen) and put it in new"Nospace" ColumnExample :I have : Hurray ! I won the GameNeeded : Hurray-I-won-the-GameCan any body helpme in getting an SQL Query for this if possibleThanks in Advance

View 4 Replies View Related

Fill Up Spaces With Dots In A Column

Sep 28, 2006


I currently have a column in a table with data type char and length 500. However, not every column fills up the entire 500 length, and I would like to fill up the rest of the spaces with dots. Is there a setting in SQL to do this? I do not want to use varchar since I want a fixed length with dots at the end. Any ideas?


View 1 Replies View Related

How To Set 0 Instead Of Blank Spaces To A Column Or Field.

Aug 20, 2007

Hi i hv a doubt in Sql server reporting..I do generate some reports based on some criteria.In the results screen i hv empty fields based on the search i hv generated.I need to set "0" instead of blank spaces in the fields..Can any one help me?

View 5 Replies View Related

Transact SQL :: Remove Trailing Spaces From A Column

Aug 31, 2015

The table I have is:

CREATE TABLE [dbo].[FTE2015](
[Firm Number] [varchar](50) NULL,
[w9] [varchar](50) NULL

select * from dbo.FTE2015
Firm Number w9
709485""   0
040898A" 12.5
709502"" 2.4
041382"" 0.4
709503"" 0.3
709681""  4.9

How do I remove the trailing blanks? I tried RTRIM but it does not work.

SELECT RTRIM([Firm Number])
FROM dbo.FTE2015;
(No column name)

How can I resolve this? The [Firm Number]column is not of a fixed length.

View 11 Replies View Related

DTS- Destination Column Name Has Spaces Causing Error

Jan 13, 2007

I am using Advantage ODBC 6.2 to connect to a Advantage Data Server to
push data from a SQL table into this server.  I can view the data from
the ADS with DTS and I can insert data by using "Insert into TempTable ("Last
Name","First Name") values ('test','test)" from a Execute SQL Statement. The issue is when I build
up a DTS package to pull from SQL into the Advantage ODBC, I get a
"missing closing ")"" error.  I have narrowed it down to the column
names in the destination table having spaces (Last Name, First Name,
and a bunch of others.  DBA 101 here).  How do I beat this?

I have tried editing the destination column names in disconnected edit
by adding the double quotes but get a "Column Name '"Last Name"' not
found" error.  Wrapping them with [] doesn't work.  I think this is a
limit on Advantage.

When I try to use Advantage OLE DB, I get an 'Ace32.dll must be newer
then the other dll" error.  I am afraid of upgrading Ace32.dll and not
break other things.


So with this said my two questions:

How do I get the destniation column names wrapped in double quotes when using transformations?


Is there a way I can do an Insert into Advantage connection(column names) values (Select Values from SQL Server connection)?

View 7 Replies View Related

Removing Characters From Column

Apr 19, 2001

I have a table called exchange and field called address. The rows(1400+) in the field look like:
MS:VA/Celcmv/;a= ;p=av;o=Celcmv;s=Doe;g=Jane;

How do I remove everything to the left of and everything to the right of using query analyzer? Thank you in advance...

View 3 Replies View Related

Removing Identity Column

Jun 26, 2001

How to remove identity property from a column throught SQL statement?

View 4 Replies View Related

Removing Characters From A Column

Sep 19, 2001

Can someone please suggest a function to remove the last 3 characters from a column? I was thinking of the LEN function, but I am unsure of the syntax.


View 5 Replies View Related

Removing Duplicate Value From One Column.

Feb 23, 2001

Hi all,
I have one table in which one column contains duplicate values. My question is how i can use T-SQL so that i can retrive values for all columns in the table which are distinct and retriving the single value from column which contains duplicate values.

(I know distinct)
Thanks in advance.


View 2 Replies View Related

Removing Text From Column Name

May 18, 2007

Hi all
i want to remove text from my column name using query.
for example
i have the product name like "silver 8' trampoline pack "
i need to remove "silver 8' " and want to display only trampoline pack
similarly if I have product name like "gold 8' trampoline pack"
i need to display only trampoline pack.
can anybody help me in this regard?


View 5 Replies View Related

Removing Identity Column

Sep 28, 2006

We can easily remove identity columnn through enterprise manager but how can it be done through transact sql?

The only way i found is to create a new column and pass values if identity column in it and then remove this identity column is there any better method of doing it?

View 1 Replies View Related

Removing Numbers From A Column

Oct 11, 2007


I have the following tables :

Code Block
Create table #EmployeeList(empname nvarchar(20), emptype char(5))

Insert INTO #EmployeeList('Cary zzz',null);
Insert INTO #EmployeeList('01 Jack',null);
Insert INTO #EmployeeList('02 Tommy',null);
Insert INTO #EmployeeList('03 Ricardo',null);
Insert INTO #EmployeeList('04 Jack',null);
Insert INTO #EmployeeList('Les zzz',null);
Insert INTO #EmployeeList('05 Tim',null);

The final data looks like this :

Cary zzz NULL
01 Jack NULL
02 Tommy NULL
03 Ricardo NULL
04 Jack NULL
Les zzz NULL
05 Tim NULL

1. I want to delete all rows which have 'zzz' in it.
2. I want to remove the numbers from the empname column

Code Block
Expected Output :

Tommy NULL
Ricardo NULL

Can anyone help me please with the query?


View 4 Replies View Related

How To Deal With Nvarchar Column

Jan 19, 2008


My company is starting to use nvarchar columns in our database products. We just found out that, suppose table T1 has a my_nvarchar_col column, and there is a row containing a unicode text say "some Chinese", if you want to select that row, you have to append "N" in front of the unicode constant in the "WHERE" clause. That is:

select * from T1
where my_nvarchar_col = N'some Chinese'

will return that row, while

select * from T1
where my_nvarchar_col = 'some Chinese'

will return NOTHING.

This brings us a huge problem - we have tens of thousands of such queries in our existing PowerBuilder code base. Do we have to go through all of them to add "N" to the "WHERE" clause? Is there a way we can set some attribute of SQL Server so that we do not need to do that?

Project stalled and I am under extreme pressure so please help ASAP!!

View 1 Replies View Related

Removing Non-numeric Digits From Column

Jun 14, 2002

Using the following:

select hl, substring(hl,1,patindex('%/%',hl)) as test
from appointment


hl test

I want to be able to remove the first 2 digits and the / to just have the clinic only remaining. Note that Y LAB is not listed in the test column..why? Any help is greatly apprecitated. Thank you....

View 4 Replies View Related

Copyrights 2005-15, All rights reserved