June 1, 2009 at 2:27 pm
Hi All,
I am trying to get the two rows on top to aligin (ltrim) and remove the leading spaces but the records but it still comes out as below. I have 348 rows that need to be combine too...
UPDATE (TABLENAME)
SET (COL1) = ltrim(COL1)
------------------------- Incorrect
TUUSALBDMC0001 col2
TUUSALBFIL3001 col2
TUUSALBDMC0001 col2
TUUSALBFIL3001 col2
?????????????????????
------------------------- Correct
TUUSALBDMC0001 col2
TUUSALBFIL3001 col2
ANY help you can offer would greatly be appreciated.
Tx, JC
June 1, 2009 at 2:36 pm
jchesnut (6/1/2009)
Hi All,I am trying to get the two rows on top to aligin (ltrim) and remove the leading spaces but the records but it still comes out as below. I have 348 rows that need to be combine too...
UPDATE (TABLENAME)
SET (COL1) = ltrim(COL1)
------------------------- Incorrect
TUUSALBDMC0001 col2
TUUSALBFIL3001 col2
TUUSALBDMC0001 col2
TUUSALBFIL3001 col2
?????????????????????
------------------------- Correct
TUUSALBDMC0001 col2
TUUSALBFIL3001 col2
ANY help you can offer would greatly be appreciated.
Tx, JC
Are trying to eliminate duplicate records from the table??
June 1, 2009 at 2:41 pm
Your 2 top rows look finely left trimmed, what are you trying to accomplish, are you trying to remove the spaces between the 2 words?
Can you explain what you are trying to do?
Cheers,
J-F
June 1, 2009 at 2:48 pm
The thread doesnt show the leading spaces on the first two rows. I dont want to delete the records I just want the leading spaces out. The records should return 180 distinct servernames and not the 348 that includes servername with leading spaces. Below is the query I run that shows all 348 "distinct" name w/ 168 servernames w/ leading spaces. I hope I answered ur question???
select distinct servername
from fs_filestats;
tx, jc
June 1, 2009 at 2:57 pm
jchesnut (6/1/2009)[hr}
select distinct servername
from fs_filestats;
then you will need to do something like this, to get the distinct trimmed server names.
select distinct LTRIM(servername) as TrimmedServerName
from fs_filestats;
Hope I understood you,
Cheers,
J-F
June 1, 2009 at 3:05 pm
I created this code but it still returns centered....aaaarrrrggggh!
I'm not sure if it matters but I used SSIS to import the data into my DB too...:w00t:
select distinct servername,
ltrim(servername)
as ServerName
from fs_filestats
order by servername
June 1, 2009 at 3:11 pm
How are you displaying things? If you are running this in SSMS, it should remove the left spaces and return the data correctly. If you doubt that, have you pasted the data into a text file to see if there are spaces?
June 1, 2009 at 3:12 pm
jchesnut (6/1/2009)
I created this code but it still returns centered....aaaarrrrggggh!I'm not sure if it matters but I used SSIS to import the data into my DB too...:w00t:
select distinct servername,
ltrim(servername)
as ServerName
from fs_filestats
order by servername
What do you mean centered, are you writing to a report, or anything?
By the way, when adding distinct to both of those columns (Servername, and Ltrim(ServerName)), the distinct will not get you the number of rows you asked earlier. It will get all distinct combinations you can have of those 2 columns, which means, all rows.
Cheers,
J-F
June 1, 2009 at 3:23 pm
j-f ur right on the code comment but when I just query servername I get all rows back. (522,760)
June 1, 2009 at 3:25 pm
sorry....it's not a report just returned in the results window at the bottom.
June 1, 2009 at 3:34 pm
steve,
When Importing the data via SSIS there are going to be random blank rows in the .dat files. When that happens it added leading spaces to the next line with data.
tx, jc
June 1, 2009 at 3:36 pm
I really appreciate all the help too!!! :w00t:
June 1, 2009 at 3:46 pm
Are you using SSMS or something else? I haven't seen anything like this centered. Do the results come back in the grid, or are you using text? I might try text to be sure there are spaces.
Or add another col and include ASCII(substring( col, 1, 1)) to see if there is a space there.
Viewing 13 posts - 1 through 12 (of 12 total)
You must be logged in to reply to this topic. Login to reply