August 2, 2010 at 9:12 am
I'm running a bat file that uses osql to return rowcount comparisons between a publisher and subscriber database. This is just a simple count(*) with a where clause, comparing rowcounts in tables that are being replicated accross domains. This is a quick check to assure that replication is working appropriately. All of the OSQL statements that point to the replication domain return the proper values. Most of the OSQL statements on the publisher are correct as well. Some of the OSQLs that run against the publisher return a rowcount of zero or 1, which is incorrect. There is no error message, and when I run the select statements from a query window they are correct. When I take each statement individually and run them from a command prompt they work as well. There are no errors reported in the output, but I would expect something besides an incorrect count to show if the query had a flaw in it.
Running 64 bit, SQL 2008 ent cluster sp2 on Windows 2008 r2. I'm running the .bat file and comand prompt on the machine that is reporting the incorrect counts.
The following doesnt returnthe correct count - but only when it is run from a bat file:
osql /E /SSTCSQL /dDB_PROD /h-1 /b /Q"set nocount on select getdate(), 'F4111 ',count(*) from [PDDTA].[F4111] WHERE (ILMCU LIKE '% 242%') OR (ILMCU LIKE '% 241%') OR (ILMCU LIKE '% 232%')" 1>>K:\DBA\count.txt 2>>K:\DBA\msg.txt" 1>>K:\DBA\count.txt 2>>K:\DBA\msg.txt
There are other similar statements that are in the .bat file that report the correct count. It doesnt seem to have any correlation to the size of the table, but it is always the same tables that return the incorrect rowcount, nd it is always on the publication server where the results are tainted. I tried changing the sequence of the queries (why I thought that would make a difference escapes me at the moment) If the syntax were incorrect or some other issue was affecting the query, shouldnt SQL be telling me that there is an error instead of just reporting a '0' or a '1' count? - that could have some pretty significant repercusions in the wrong circumstances. Here, I just have to re-check the counts.
Ive been writing and using bat scripts for years, but this is my first forray into the 64 bit environment. Could that have a bearing on the issue? The subscriber is a 32 bit server, the Publisher/distributor is 64. The queries, in most cases work as intended, just about 10 of the 28 queries return a zero or a 1 value, when it should be in the thousands. Like I've said, the OSQL works fine from a command prompt. Just not in a .bat file.
August 2, 2010 at 10:11 am
osql /E /SSTCSQL /dDB_PROD /h-1 /b /Q"set nocount on select getdate(), 'F4111 ',count(*) from [PDDTA].[F4111] WHERE (ILMCU LIKE '% 242%') OR (ILMCU LIKE '% 241%') OR (ILMCU LIKE '% 232%')" 1>>K:\DBA\count.txt 2>>K:\DBA\msg.txt" 1>>K:\DBA\count.txt 2>>K:\DBA\msg.txt
Note sure why 1>>K:\DBA\count.txt 2>>K:\DBA\msg.txt" 1>>
is appearing twice.
Pradeep Adiga
Blog: sqldbadiaries.com
Twitter: @pradeepadiga
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply