all groups > sql server data mining > october 2005 >
You're in the

sql server data mining

group:

Q: on stored procedure


Re: on stored procedure Ana
10/10/2005 12:00:00 AM
sql server data mining:
Hello Adam,
I added the ORDER BY clause but didn't make a change.

"Adam Machanic" <amachanic@hotmail._removetoemail_.com> escribió en el
mensaje news:OozPWoZzFHA.3856@tk2msftngp13.phx.gbl...
[quoted text, click to view]

Re: on stored procedure Ana
10/10/2005 12:00:00 AM
Hello again,
I cannot add the DLL for being too complex but I added the stored procedure
if it can be of help.
Thanks again.

SELECT dbo.CLAIMS.CLAIM_ID, dbo.CONCESIONARIO.CONCESIONARIO_NOMBRE,
dbo.COMERCIALES.COMERCIAL_APELLIDOS,
CAST(dbo.CLAIMS.DATE_OF_CLAIM AS DATETIME) AS D_CLAIM,
dbo.CLAIMS.AGENT_ID
FROM dbo.CLAIMS INNER JOIN
dbo.CLIENTS ON dbo.CLAIMS.CLIENT_ID =
dbo.CLIENTS.CLIENT_ID INNER JOIN
dbo.AGENTS ON dbo.CLAIMS.AGENT_ID =
dbo.AGENTS.AGENT_ID AND
dbo.CLAIMS.AGENT_ID = dbo.AGENTS.AGENT_ID
WHERE (dbo.CLAIMS.AGENT_ID = @Agent) AND (CAST(dbo.CLAIMS.DATE_OF_CLAIM
AS DATETIME) BETWEEN @D_Start AND
@D_End)
ORDER BY dbo.CLAIMS.CLAIM_ID

"Adam Machanic" <amachanic@hotmail._removetoemail_.com> escribió en el
mensaje news:OzgE40bzFHA.1028@TK2MSFTNGP12.phx.gbl...
[quoted text, click to view]

Q: on stored procedure Ana
10/10/2005 12:00:00 AM
Hi,

In a stored procedure I've a WHERE condition which asks for the following
date parameters:

BETWEEN @D_Start AND @D_End

When I run the query, the window comes up with D_END and then with D_Start.

The strange thing is that D_Start should come up first and then D_End. An
other phenomenon is that D_End is converted to upper case to D_END.

I'm lost. Why is this happening?

TIA

Ana

Re: on stored procedure Adam Machanic
10/10/2005 8:56:32 AM
Do you need to add an ORDER BY clause to your query?

There is never implicit ordering guaranteed for any query.


--
Adam Machanic
SQL Server MVP
http://www.datamanipulation.net
--


[quoted text, click to view]

Re: on stored procedure Adam Machanic
10/10/2005 1:07:58 PM
I'm not really understanding your question, then. Can you provnide DDL and
sample data, as well as the full query?

See: www.aspfaq.com/etiquette.asp?id=5006


--
Adam Machanic
SQL Server MVP
http://www.datamanipulation.net
--


[quoted text, click to view]

Re: on stored procedure Adam Machanic
10/10/2005 1:51:26 PM
[quoted text, click to view]

You're ordering by the CLAIM_ID; why would you expect this to influence
the ordering of DATE_OF_CLAIM?

Try:

ORDRY BY dbo.CLAIMS.DATE_OF_CLAIM

By the way, why are you casting the date? Doing so will ruin index
utilization.


--
Adam Machanic
SQL Server MVP
http://www.datamanipulation.net
--



Re: on stored procedure Mike
10/11/2005 12:18:36 AM
CLAIM_ID is a giving number (CLAIM #) and the dates are stored in a strange
format: yyyymmdd.

"Adam Machanic" <amachanic@hotmail._removetoemail_.com> escribió en el
mensaje news:uajuINczFHA.720@TK2MSFTNGP15.phx.gbl...
[quoted text, click to view]

AddThis Social Bookmark Button