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 '

Thanks.

View 5 Replies


ADVERTISEMENT

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')
INSERT INTO @ColumnSpaces VALUES ('AAAAAAAAAAAAAAA', '123')

View 6 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

Hello,

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

postcode|carrier_code|available|depot_code|hub_code|county_code
----------------------------------------------------------------
EX15.....|NF/S93......|........1|34........|C.......|DEVO
EX15.....|NF/SAT......|........1|34........|C.......|DEVO
EX15.....|NF/930......|........1|34........|C.......|DEVO
EX15.....|NF/AM.......|........1|34........|C.......|DEVO
EX15.....|NF/ON.......|........1|34........|C.......|DEVO
EX15.....|NF/48.......|........1|34........|C.......|DEVO
EX15.....|NF/3D.......|........1|34........|C.......|DEVO

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

postcode|carrier_code|available|depot_code|hub_code|county_code
----------------------------------------------------------------
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

Thanks

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 funny.here 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

Removing Spaces From An Nvarchar Column

Jul 20, 2005

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

View 1 Replies View Related

Fill Up Spaces With Dots In A Column

Sep 28, 2006

Hi,

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?

Thanks,
Alan

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

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

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
) ON [PRIMARY]
GO

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)
709485""
040898A"
709502""
041382""
709503""

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?

or

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

Integration Services :: SSIS - Data Load To Excel - How To Retain Trailing Spaces In Text Column

May 8, 2015

I am loading data using SSIS 2008 from a table in SQL Server 2008 DB to excel 97 sheet pre-defined with column headers. All the columns in excel is has 'Text' format property and the columns in the SQL Server table are defined as nVarchar. One of the columns has trailing spaces in few rows in DB but after exporting to excel 97, the spaces are gone. We need to retain the whitespaces in the column values. How can we do that.

View 3 Replies View Related

SPACES

Sep 24, 2001

Please how can remove spaces on a date field and a text field. THanks.

View 1 Replies View Related

Spaces In A Sql Server

Nov 19, 2007

i collected the users information without using any trim fucntion(i have implemented now)
but the data which has been already posted into my server has text with some white spaces at the beginning of data
now how to remove this white spaces in this column in online server data.
the data is something like this
mycolumn 
data
  data
data
    data
 
so how to remove white spaces in the above column

View 3 Replies View Related

Add SPACES In Data

Apr 22, 2008

Hi
i have 1 query please guide me,
SELECT P.ProjectName, REPLACE(SPACE(TU.TaskOutlineLevel), ' ', '__') AS dash,TU.TASKISSUMMARY AS TASKSUMMARY,
here i want to add  BLANKS but not working so i have to show add spaces using  __ here any idea i can add SPACES or '  ' here.
please let me know if any. basically i want to align the data in my GRIDVIEW
Thanks in advance
Parth

View 4 Replies View Related

Remove Spaces

Apr 12, 2006

How can you remove spaces in the middle of a string, RTRIM and LTRIM does not work

View 1 Replies View Related

White Spaces

Jan 8, 2002

Creating a text file using DTS, is there a function/way to take out white
spaces from columns. Example:
'1234 ','567 ' would come in text as
'1234','567'

Thanks in advance.

View 2 Replies View Related

Spaces On An Insert

Jan 7, 2003

Hi,

I am building my insert statements dynamically and am finding that there are spaces after certain integer fields.

example Insert Table A (col1, col2, col3)
values (1 ,'2',3 )

If col1 and col3 are integer fields, is there any affect to either how the value is stored or how it will be retrieved when the table is used in a join. By inspecting the values in the table, it seems fine. Do I need to worry?

Thanks,

Jim

View 1 Replies View Related

Trailing Spaces

Apr 28, 2003

If I run SELECT Len(' ') it returns 0, if SELECT Len('a ') it returns 1
I need this to return the correct length including the space that on the end. I thought it was an ansi_padding problem but even turning padding on results in a 0 length. Any ideas? Thanks!

Todd

View 2 Replies View Related

Erasing Spaces!

Apr 28, 2004

--------------------------------------------------------------------------------

I am tring to join two tables. There is one problem of course. There is one column I would be able to join the two tables by. This column would be Loc_Code. The only problem is that both columns are not exactly the same. They look like this:

Table 1 Table 2
Loc_Code Loc_Code
A 12345 A12345
A 12346 A12346
A 12347 A12347
A 12348 A12348

I need to erase the spaces that exists in the Loc_Code column in table 1 so that I can join with table 2.


All help would be appreciated.

View 9 Replies View Related

Trimming Spaces

Mar 9, 2006

I need to trim what looks like two spaces from a field.

Example:

" 601274" needs to be "601274". Does anyone know the syntax?+

View 9 Replies View Related

Remove Spaces

Jan 25, 2007

is there a way to do remove spaces from a string if its they are in deifferent places on each row

View 1 Replies View Related

How To Ignore Spaces?

Jan 31, 2008

I'm writing a store procedure to accept search strings from user on my site. Currently, this is what I have.




Code Snippet
@schoolID int = NULL,
@scholarship varchar(250) = NULL,
@major varchar(250) = NULL,
@requirement varchar(250) = NULL
--@debug bit = 0
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
SELECT * FROM [scholarship]
WHERE ([sectionID] = @schoolID OR @schoolID IS NULL)
AND ([schlrPrefix] LIKE '%' + @scholarship + '%' OR [schlrName] LIKE '%' + @scholarship + '%' OR [schlrSufix] LIKE '%' + @scholarship + '%' OR @scholarship IS NULL )
AND ([Specification] LIKE '%' + @major + '%' OR @major IS NULL )
AND ([reqr1] LIKE '%' + @requirement + '%' OR [reqr2] LIKE '%' + @requirement + '%' OR [reqr3] LIKE '%' + @requirement + '%' OR [reqr4] LIKE '%' + @requirement + '%' OR [reqr5] LIKE '%' + @requirement + '%' OR @requirement IS NULL )





The problem is, somtimes the search doesn't work if there is a space behind or infront of the search string. I wonder if there is away to ignore any spaces and go right into whatever character comes next or after. If so, how do I implement that?

View 7 Replies View Related

Trailing Spaces - Such A Pain...

Dec 31, 2006

Hi All...  I'm using a SQL Server 2005 database.  I've noticed that columns that are declared as "char" and that have a fixed size tend to put trailing spaces at the end of the data when I pull it out.  I guess I can understand why...  But it's a pain dealing with it.   As I'm bringing my application up, I can see spaces all over the place - I just havent gotten around to doing anything about it yet.  What's the easiest/best way to get rid of those spaces.  Geez, it'd be real cool if I could put something in the SELECT statement.  Any thoughts?  Thanks much!!  -- Curt
 

View 1 Replies View Related

Find Leading Spaces

Aug 23, 2001

What is the best way to check for leading spaces in your table, using ltrim?
Such as TableA(name, city)
the data in TableA Smith Dallas
John New York
Greg Richmond
David Chicago
Return only David.

View 1 Replies View Related

Spaces In SQL 7 Database Names

Mar 7, 2000

Hey all,

Hope I can get some help here.

Have a view that has to reference a table in another database on the same server. This isn't the problem. I am just using Databasename..tablename in the from statement. Get the results required in testing.

The problem is that in production the table name has a space character. i.e. 'accounting info' would be the table name. I have not been able to figure out the proper syntax to capture this properly to reference in the from statement.

I have tried enclosing the name in ' ', " ", [], (), {} and just about every combination I can come up with.

Any help in this would be great, and changing the databse name isn't an option at this time.

Thanx,
Chris

View 3 Replies View Related

Replace Null With Spaces

Sep 4, 2003

Hi all smart people,

Can someone please help me with how to replace null values with spaces in select statement.

I have to have a select statement which will select all the data but the field contain null value it has to replace with spaces. How can I do that ?

Thanks,

View 7 Replies View Related

Extra Spaces In Rows

Jul 10, 2006

I have some fields in my database that are char(50)

I use an insert to put some text into the fields (using perl)
when I look at the fields I find that spaces are used to "pad out" the text to the field size.

This didn't happen with MySQL and PHP, is there any way to disable this?

View 5 Replies View Related

Error In Replace With Spaces

Jun 2, 2004

Hi !
I'm trying to put a space after . and , in varchar fields.

I've tried

UPDATE Resultados
SET RespuestaAbierta = REPLACE(RespuestaAbierta, ',', ', ')

but nothing happened

What's wrong ??

Thanks and sorry if my english isn´t so good.

Eduardo (from Argentina)

View 9 Replies View Related

HELP! How To Reduce The Unused Spaces ..

Aug 9, 2004

HI all,

I have a database that allocated:

Data: 7300 MB
Log: 2000 MB

But only used

Data: 5500MB
Log: 50MB

How can I free the unused space in the transaction log because
the database is getting too big.

Thank you for your suggestion.

View 1 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







Copyrights 2005-15 www.BigResource.com, All rights reserved