|
Posted by Erland Sommarskog on 12/27/06 22:46
ice (iceruam@gmail.com) writes:
> I was not able to make it work, getting an a error about a relation.*
Seeing your tables and your COPY commands, it's apparent to me that
whatever you are using, it is not Microsoft SQL Server. The solution
I posted is almost ANSI-compliant. The exception is the expression:
datedadd(day, -30, getdate())
In ANSI SQL, getdate() should be CURRENT_TIMESTAMP. Whether dateadd (my
query mistakely had "datedadd" I see now) is in ANSI SQL, I don't know,
nor do I know about date aritmethics in general in ANSI SQL.
Thus, theoretically, beside this expression, the solution should work
if your DB engine implements the same ANSI constructs as SQL Server does.
Alas, just because a query is ANSI-compliant, does not mean that it
will run all engines, so you may have to use a solution that uses
syntax peculiar to the product that you work with. If you need help
with that, you will have to find a forum for your product. If that
product is mysql, there is a comp.databases.mysql nextdoors from here.
--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
[Back to original message]
|