Quantcast
Channel: ฟอรัม Getting started with SQL Server
Viewing all articles
Browse latest Browse all 8428

Same query producing different record counts on two different machines

$
0
0

I am running a sql server query on two different machines but connected to same server and same database. This query is used to remove all the padding and provide a clean data. 

SELECT DISTINCT REPLACE(REPLACE(REPLACE(LTRIM(RTRIM(REPLACE(col1, CHAR(13), ''))),'',''),'/',''),CHAR(10),'')
FROM [dbo].tbl1
WHERE LEN(REPLACE(REPLACE(REPLACE(LTRIM(RTRIM(REPLACE(col1, CHAR(13), ''))),'',''),'/',''),CHAR(10),''))<>0
ORDER BY 1 ASC

Machine 'A' is giving me 122 records while machine 'B' is giving me 134 records. Any idea what might be the cause of this?

I did order by on both the machines, and first row on machine 'A' is an actual value like 1234 and first value on machine 'B' is a blank record.

Sample data set:




1
2
3
4

As you can see the records before '1' are either blank or new line and that is why I am doing all the padding so as to get clean data

I even executed the same query in another SSMS instance and restarted the entire server, but still no avail

Thanks in advance!!



Viewing all articles
Browse latest Browse all 8428

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>