Showing posts with label programming. Show all posts
Showing posts with label programming. Show all posts

Friday, February 24, 2012

a query that doesnt work

Hi, im programming to a Database over Access2000, and i had done this
query:
SELECT Sum(Importe) As SumaDia FROM [Diario Caja] WHERE Fecha between
#03/05/2006 10:57:45# and #03/05/2006 12:57:45#
the answer is null, but if i use a query like that
SELECT Sum(Importe) As SumaDia FROM [Diario Caja] WHERE Fecha between
date1 and date2
and instead of variables use the literals (#03/05/2006 12:57:45#) it
works.
i dont know why, can someone help me
Sorry for my english i know there are a lot of mistakes on it.
Thanks every oneIf you're connecting to a SQL Server database - and that's what this
newsgroup is about - use single quotes to delimit datetime constants:
SELECT Sum(Importe) As SumaDia FROM [Diario Caja] WHERE Fecha between
'03/05/2006 10:57:45' and '03/05/2006 12:57:45'
Tom
----
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Toronto, ON Canada
.
"Bardanca" <Bardanca@.gmail.com> wrote in message
news:1146655492.968842.253080@.v46g2000cwv.googlegroups.com...
Hi, im programming to a Database over Access2000, and i had done this
query:
SELECT Sum(Importe) As SumaDia FROM [Diario Caja] WHERE Fecha between
#03/05/2006 10:57:45# and #03/05/2006 12:57:45#
the answer is null, but if i use a query like that
SELECT Sum(Importe) As SumaDia FROM [Diario Caja] WHERE Fecha between
date1 and date2
and instead of variables use the literals (#03/05/2006 12:57:45#) it
works.
i dont know why, can someone help me
Sorry for my english i know there are a lot of mistakes on it.
Thanks every one|||Bardanca (Bardanca@.gmail.com) writes:
> Hi, im programming to a Database over Access2000, and i had done this
> query:
> SELECT Sum(Importe) As SumaDia FROM [Diario Caja] WHERE Fecha between
> #03/05/2006 10:57:45# and #03/05/2006 12:57:45#
> the answer is null, but if i use a query like that
> SELECT Sum(Importe) As SumaDia FROM [Diario Caja] WHERE Fecha between
> date1 and date2
> and instead of variables use the literals (#03/05/2006 12:57:45#) it
> works.
> i dont know why, can someone help me
You are better off asking in an Access newsgroup, as there are considerable
differences between Access and SQL Server.
The obvious thing I would think of is regional settings. Is that May 3rd
or March 5th?
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx|||Tom Moreau (tom@.dont.spam.me.cips.ca) writes:
> If you're connecting to a SQL Server database - and that's what this
> newsgroup is about - use single quotes to delimit datetime constants:
> SELECT Sum(Importe) As SumaDia FROM [Diario Caja] WHERE Fecha between
> '03/05/2006 10:57:45' and '03/05/2006 12:57:45'
And use a date format of YYYYMMDD, as the above could be interpreted as
May 3rd or March 5th depending on settings. YYYYMMDD is unambiguous.
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx

Thursday, February 9, 2012

a General database question. Please help urgent!

guys i have a programming question i have table called prerequsites
which is like this
prerequisite component component
a b
so inside my before insert trigger i have to check if the prerequisite is a valid entry like for instance
an entry like b is a prerequisite component for component a which is not a valid entry since i already have an entry in the prerequisite table which defines that comonent a is a prerequisite of b. however this is
very basic so i can test it easy some thing like this in my before insert
prerequisite component component
a b
b a ( Not a valid entry)
select count(*) from prerequisite where component = value of prerequisite component
and prerequisite component = value of component
the above select statement will actually tell me if entry is allowed for insert and does not override other prerequsites
but it can get very complex depending on how the user chooses so if someone can tell me a nice algorithm or good logic to approach this problem it would be great like for instance
prerequisite component component
a b
b c
c a ( Not a valid entry. so how do i ensure that this entry is not allowed considering that complexity for prerequsites can increase quite greatly)
please can someone tell me how to approach this problem.

Try these links for INSTEAD OF Triggers, you can do things within the Trigger. Hope this helps.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnsqlpro01/html/sql01a17.asp

http://www.databasejournal.com/features/mssql/article.php/1437741