Showing posts with label wheni. Show all posts
Showing posts with label wheni. Show all posts

Friday, March 30, 2012

Problems with transactional replication

Hello All!
Today I've found one strange problem ... I have tables like
something_another_2004_9 (so name_YEAR_MONTH) ... funny thing happened when
I got to the month 10,
I see that the insert/update/delete stored procedures are missing the last
digit in their name.
So, for the 2004_9 month I get sp_MSins_something_another_2004_9,
sp_MSupd_something_another_2004_9, etc .
But for the 2004_10 month I get sp_MSins_something_another_2004_1,
sp_MSupd_something_another_2004_1 ... where is the last 0!? Same happened
for 2004_11 table.
What could be the problem? Are the table names too long or what ?!
Thanks four your input!
Kind regards,
Dejan
can you post the exact names of the tables which are causing the problems
with stored procedure generation?
Hilary Cotter
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602.html
"Dejan Markic" <dejan@.akton.is> wrote in message
news:hy2fd.4744$F6.1274490@.news.siol.net...
> Hello All!
> Today I've found one strange problem ... I have tables like
> something_another_2004_9 (so name_YEAR_MONTH) ... funny thing happened
when
> I got to the month 10,
> I see that the insert/update/delete stored procedures are missing the last
> digit in their name.
> So, for the 2004_9 month I get sp_MSins_something_another_2004_9,
> sp_MSupd_something_another_2004_9, etc .
> But for the 2004_10 month I get sp_MSins_something_another_2004_1,
> sp_MSupd_something_another_2004_1 ... where is the last 0!? Same happened
> for 2004_11 table.
> What could be the problem? Are the table names too long or what ?!
> Thanks four your input!
> Kind regards,
> Dejan
>
>
|||Hello!
Sorry for the late response ...
Full table names are:
billing_record_2004_9, billing_record_2004_10 ...
Paul,
I see normal procs name (without missin last number) ... I don't know if
this makes any difference, but before I ran that I already 'repaired' this
by hand (renaming and creating new procs for this new tables). I'm just
afraid that this will happen again next month (12 = two letters ) Can I
check that somehow ? What could be the case here?
Kind regards,
Dejan
"Hilary Cotter" <hilary.cotter@.gmail.com> wrote in message
news:ebe9KdouEHA.1404@.TK2MSFTNGP11.phx.gbl...
| can you post the exact names of the tables which are causing the problems
| with stored procedure generation?
|
| --
| Hilary Cotter
| Looking for a SQL Server replication book?
| http://www.nwsu.com/0974973602.html
|
|
| "Dejan Markic" <dejan@.akton.is> wrote in message
| news:hy2fd.4744$F6.1274490@.news.siol.net...
| > Hello All!
| >
| > Today I've found one strange problem ... I have tables like
| > something_another_2004_9 (so name_YEAR_MONTH) ... funny thing happened
| when
| > I got to the month 10,
| > I see that the insert/update/delete stored procedures are missing the
last
| > digit in their name.
| > So, for the 2004_9 month I get sp_MSins_something_another_2004_9,
| > sp_MSupd_something_another_2004_9, etc .
| > But for the 2004_10 month I get sp_MSins_something_another_2004_1,
| > sp_MSupd_something_another_2004_1 ... where is the last 0!? Same
happened
| > for 2004_11 table.
| > What could be the problem? Are the table names too long or what ?!
| >
| > Thanks four your input!
| >
| > Kind regards,
| > Dejan
| >
| >
| >
| >
|
|

Friday, March 23, 2012

Problems with queries on Win 2003 server

I am running into lot of problems with queries when
I run it on a windows 2003 server having Sql 2000 SP3A
pack.
I was able to run the following query just fine on
Windows NT with Sql 7 -
SELECT filing_area, File_num, contract_num, * from
eng_file where filing_area+ COALESCE(file_num, 'TEST') +
COALESCE(contract_num, 'TEST')
in (select filing_area + COALESCE(file_num, 'TEST') +
COALESCE(contract_num, 'TEST') from eng_file
group by filing_area + COALESCE(file_num, 'TEST') +
COALESCE(contract_num, 'TEST') having count(*) > 1 )
But the same query gives me the following errors
when run on Win 2003 with Sql 2000 SP3 or Win 2k with Sql
2k sp3.
Server: Msg 8120, Level 16, State 1, Line 1
Column 'eng_file.FILING_AREA' is invalid in the select
list because it is not contained in either an aggregate
function or the GROUP BY clause.
Server: Msg 8120, Level 16, State 1, Line 1
Column 'eng_file.FILE_NUM' is invalid in the select list
because it is not contained in either an aggregate
function or the GROUP BY clause.
Server: Msg 8120, Level 16, State 1, Line 1
Column 'eng_file.FILE_NUM' is invalid in the select list
because it is not contained in either an aggregate
function or the GROUP BY clause.
Server: Msg 8120, Level 16, State 1, Line 1
Column 'eng_file.CONTRACT_NUM' is invalid in the select
list because it is not contained in either an aggregate
function or the GROUP BY clause.
Server: Msg 8120, Level 16, State 1, Line 1
Column 'eng_file.CONTRACT_NUM' is invalid in the select
list because it is not contained in either an aggregate
function or the GROUP BY clause.
What I am missing?
Thank you,
-Li
The behaviour of queries with expressions in the GROUP BY list doesn't
always seem very logical. I don't have 7.0 to verify but the following query
should work on both versions. In your IN comparison, notice that (a1+b1+c1 =
a2+b2+c2) is NOT the same comparison as (a1=a2, b1=b2, c1=c2) if these
values are variable-lengths strings. Unless the strings are CHAR or VARCHAR
of equal length then the result of your query may not be what I think you
intended.
SELECT T1.filing_area, T1.file_num, T1.contract_num, *
FROM eng_file AS T1
JOIN
(SELECT filing_area,
COALESCE(file_num, 'TEST'),
COALESCE(contract_num, 'TEST')
FROM eng_file
GROUP BY filing_area,
COALESCE(file_num, 'TEST'),
COALESCE(contract_num, 'TEST')
HAVING COUNT(*)>1)
AS T2(filing_area, file_num, contract_num)
ON T1.filing_area = T2.filing_area
AND COALESCE(T1.file_num, 'TEST') = T2.file_num
AND COALESCE(T1.contract_num, 'TEST') = T2.contract_num
David Portas
SQL Server MVP
|||Your original query works on SQL Server 2005 (9.00.852), so although it
doesn't help you now it does appear that the problem has been fixed. :-)
David Portas
SQL Server MVP
|||Li,
This certainly looks like a bug to me. I believe your query will
succeed if you replace COALESCE by ISNULL. The two functions are not
identical, however. The data type of COALESCE(x,y) accommodates all
the arguments, but the type of ISNULL(x,y) is the type of x. Also,
COALESCE takes multiple arguments and ISNULL must be nested.
I'll pass this on to Microsoft, since I have not seen it reported
before. Thanks!
Steve Kass
Drew University
Li wrote:

>I am running into lot of problems with queries when
>I run it on a windows 2003 server having Sql 2000 SP3A
>pack.
>I was able to run the following query just fine on
>Windows NT with Sql 7 -
>SELECT filing_area, File_num, contract_num, * from
>eng_file where filing_area+ COALESCE(file_num, 'TEST') +
>COALESCE(contract_num, 'TEST')
>in (select filing_area + COALESCE(file_num, 'TEST') +
>COALESCE(contract_num, 'TEST') from eng_file
>group by filing_area + COALESCE(file_num, 'TEST') +
>COALESCE(contract_num, 'TEST') having count(*) > 1 )
>But the same query gives me the following errors
>when run on Win 2003 with Sql 2000 SP3 or Win 2k with Sql
>2k sp3.
>Server: Msg 8120, Level 16, State 1, Line 1
>Column 'eng_file.FILING_AREA' is invalid in the select
>list because it is not contained in either an aggregate
>function or the GROUP BY clause.
>Server: Msg 8120, Level 16, State 1, Line 1
>Column 'eng_file.FILE_NUM' is invalid in the select list
>because it is not contained in either an aggregate
>function or the GROUP BY clause.
>Server: Msg 8120, Level 16, State 1, Line 1
>Column 'eng_file.FILE_NUM' is invalid in the select list
>because it is not contained in either an aggregate
>function or the GROUP BY clause.
>Server: Msg 8120, Level 16, State 1, Line 1
>Column 'eng_file.CONTRACT_NUM' is invalid in the select
>list because it is not contained in either an aggregate
>function or the GROUP BY clause.
>Server: Msg 8120, Level 16, State 1, Line 1
>Column 'eng_file.CONTRACT_NUM' is invalid in the select
>list because it is not contained in either an aggregate
>function or the GROUP BY clause.
>
>What I am missing?
>Thank you,
>-Li
>
>
|||Li,
A better workaround (I only checked a simpler query) is to replace
COALESCE(x,y) with CASE WHEN x IS NULL THEN x ELSE y END, which is
equivalent. I think the bug here is a parsing problem that comes up if
a subquery groups on a CASE WHEN NOT ... expression, which is how the
COALESCE must be getting rewritten.
SK
Li wrote:

>I am running into lot of problems with queries when
>I run it on a windows 2003 server having Sql 2000 SP3A
>pack.
>I was able to run the following query just fine on
>Windows NT with Sql 7 -
>SELECT filing_area, File_num, contract_num, * from
>eng_file where filing_area+ COALESCE(file_num, 'TEST') +
>COALESCE(contract_num, 'TEST')
>in (select filing_area + COALESCE(file_num, 'TEST') +
>COALESCE(contract_num, 'TEST') from eng_file
>group by filing_area + COALESCE(file_num, 'TEST') +
>COALESCE(contract_num, 'TEST') having count(*) > 1 )
>But the same query gives me the following errors
>when run on Win 2003 with Sql 2000 SP3 or Win 2k with Sql
>2k sp3.
>Server: Msg 8120, Level 16, State 1, Line 1
>Column 'eng_file.FILING_AREA' is invalid in the select
>list because it is not contained in either an aggregate
>function or the GROUP BY clause.
>Server: Msg 8120, Level 16, State 1, Line 1
>Column 'eng_file.FILE_NUM' is invalid in the select list
>because it is not contained in either an aggregate
>function or the GROUP BY clause.
>Server: Msg 8120, Level 16, State 1, Line 1
>Column 'eng_file.FILE_NUM' is invalid in the select list
>because it is not contained in either an aggregate
>function or the GROUP BY clause.
>Server: Msg 8120, Level 16, State 1, Line 1
>Column 'eng_file.CONTRACT_NUM' is invalid in the select
>list because it is not contained in either an aggregate
>function or the GROUP BY clause.
>Server: Msg 8120, Level 16, State 1, Line 1
>Column 'eng_file.CONTRACT_NUM' is invalid in the select
>list because it is not contained in either an aggregate
>function or the GROUP BY clause.
>
>What I am missing?
>Thank you,
>-Li
>
>
|||Li,
ISNUll worked - thank you.
Please do let me know if you get a chance to report
this to Microsoft and their reaction to it.
Thank you,
-Li

>--Original Message--
>Li,
> This certainly looks like a bug to me. I believe your
query will
>succeed if you replace COALESCE by ISNULL. The two
functions are not
>identical, however. The data type of COALESCE(x,y)
accommodates all
>the arguments, but the type of ISNULL(x,y) is the type
of x. Also,
>COALESCE takes multiple arguments and ISNULL must be
nested.
> I'll pass this on to Microsoft, since I have not seen
it reported[vbcol=seagreen]
>before. Thanks!
>Steve Kass
>Drew University
>Li wrote:
+[vbcol=seagreen]
Sql[vbcol=seagreen]
list[vbcol=seagreen]
list
>.
>
|||Steve,
I agree the query may not be the best one as it was
written to quickly take care of some data issues we are
facing and came up with this. Since it worked fine on Sql
7.0, I don't find any reason for it not to work with Sql
2K. David mentioned that it works on Sql 2k so the
problem may have been fixed. What am I missing that it
isn't working for me?
Any ideas?
I am going to write to David too.
Thank you very much for yout time and input -
-Li

>--Original Message--
>Li,
> A better workaround (I only checked a simpler query)
is to replace
>COALESCE(x,y) with CASE WHEN x IS NULL THEN x ELSE y
END, which is
>equivalent. I think the bug here is a parsing problem
that comes up if
>a subquery groups on a CASE WHEN NOT ... expression,
which is how the[vbcol=seagreen]
>COALESCE must be getting rewritten.
>SK
>Li wrote:
+[vbcol=seagreen]
Sql[vbcol=seagreen]
list[vbcol=seagreen]
list
>.
>
|||Steve,
Ignore my comments about why it isn't working for me.
When I went to reply to DAvid's email, I noticed that he
said it is fixed on 2005 and not 2000, that answers my
question.
-Li
>--Original Message--
>Li,
> A better workaround (I only checked a simpler query)
is to replace
>COALESCE(x,y) with CASE WHEN x IS NULL THEN x ELSE y
END, which is
>equivalent. I think the bug here is a parsing problem
that comes up if
>a subquery groups on a CASE WHEN NOT ... expression,
which is how the[vbcol=seagreen]
>COALESCE must be getting rewritten.
>SK
>Li wrote:
+[vbcol=seagreen]
Sql[vbcol=seagreen]
list[vbcol=seagreen]
list
>.
>