Showing posts with label syntax. Show all posts
Showing posts with label syntax. Show all posts

Friday, March 9, 2012

Divide by Zero error

With the following sql I get a divide by zero error. Can somebody help me
with the syntax to fix this?
Thanks in advance
SUM(CASE WHEN (p.SecondaryCapacity/p.SecondaryWatts) < (m.SecondaryEERSpec -
(-1 * (@.LowerSpec * m.SecondaryEERSpec))) OR
(p.SecondaryCapacity/p.SecondaryWatts) > (m.SecondaryEERSpec +
(@.UpperSpec * m.SecondaryEERSpec)) THEN 1 Else 0 END) as SecondaryEERFailure
sHow about checking for p.SecondaryWatts first?
SUM(
CASE WHEN (p.SecondaryWatts =0) THEN -1
WHEN (p.SecondaryCapacity/p.SecondaryWatts) <
(m.SecondaryEERSpec - (-1 * (@.LowerSpec * m.SecondaryEERSpec)))
OR
(p.SecondaryCapacity/p.SecondaryWatts) > (m.SecondaryEERSpec +
(@.UpperSpec * m.SecondaryEERSpec))
THEN 1 Else 0 END
) as SecondaryEERFailures
"StvJston" wrote:

> With the following sql I get a divide by zero error. Can somebody help me
> with the syntax to fix this?
>
> Thanks in advance
> SUM(CASE WHEN (p.SecondaryCapacity/p.SecondaryWatts) < (m.SecondaryEERSpec
-
> (-1 * (@.LowerSpec * m.SecondaryEERSpec))) OR
> (p.SecondaryCapacity/p.SecondaryWatts) > (m.SecondaryEERSpec +
> (@.UpperSpec * m.SecondaryEERSpec)) THEN 1 Else 0 END) as SecondaryEERFailu
res
>|||Kevin,
Thanks for your reply. I just got it figured out and did just what you
suggested.
SUM(CASE WHEN p.SecondayWatts = 0 THEN 0
ELSE CASE WHEN (p.SecondaryCapacity/p.SecondaryWatts) <
(m.SecondaryEERSpec - (-1 * (@.LowerSpec * m.SecondaryEERSpec))) OR
(p.SecondaryCapacity/p.SecondaryWatts) > (m.SecondaryEERSpec +
(@.UpperSpec * m.SecondaryEERSpec)) THEN 1 Else 0 END END) as
SecondaryEERFailures,
"Kevin Bowker" wrote:
> How about checking for p.SecondaryWatts first?
> SUM(
> CASE WHEN (p.SecondaryWatts =0) THEN -1
> WHEN (p.SecondaryCapacity/p.SecondaryWatts) <
> (m.SecondaryEERSpec - (-1 * (@.LowerSpec * m.SecondaryEERSpec)))
> OR
> (p.SecondaryCapacity/p.SecondaryWatts) > (m.SecondaryEERSpec +
> (@.UpperSpec * m.SecondaryEERSpec))
> THEN 1 Else 0 END
> ) as SecondaryEERFailures
> "StvJston" wrote:
>

Friday, February 24, 2012

Distribution Agent Error: Syntax error or access violation

I am getting this error in the distribution agent that I setup for
transactional replication. The last command which failed is like "CALL
sp_MSins_CompanyName$Trans_ Sales Entry ("
The table name is lengthy and contains spaces too. I believe this is because
of the spaces in the stored procedure name which is causing the syntax
error.
The problem is, I cant rename the tables to ommit the spaces. Isnt there any
way to rename the stored procedures and relink them with the new name so
that the new renamed procedure should be called rather than system keep on
looking for the procedure with the original name?
If there any solution in SQL for this issue that would be great otherwise I
must have to do some workaround if possible.
Muhammad
When you create your publication you can specify the name of the stored
procedure you wish to use. SQL Server will autogenerate that stored
procedure with the name.
Hilary Cotter
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602.html
Looking for a FAQ on Indexing Services/SQL FTS
http://www.indexserverfaq.com
"Muhammad Shahzad Saleem" <msaleem@.simplywireless.com> wrote in message
news:uJ9xOIuHHHA.1044@.TK2MSFTNGP02.phx.gbl...
>I am getting this error in the distribution agent that I setup for
>transactional replication. The last command which failed is like "CALL
>sp_MSins_CompanyName$Trans_ Sales Entry ("
> The table name is lengthy and contains spaces too. I believe this is
> because of the spaces in the stored procedure name which is causing the
> syntax error.
> The problem is, I cant rename the tables to ommit the spaces. Isnt there
> any way to rename the stored procedures and relink them with the new name
> so that the new renamed procedure should be called rather than system keep
> on looking for the procedure with the original name?
> If there any solution in SQL for this issue that would be great otherwise
> I must have to do some workaround if possible.
> Muhammad
>