Print Page | Close Window

DB query

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=7319
Printed Date: 29 March 2026 at 2:08am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: DB query
Posted By: hack_it
Subject: DB query
Date Posted: 16 November 2003 at 2:03pm

i have an orders table and i am tryin to insert these orders into a history table at the end of each day. i'm using an insert select statement.

this is working fine but was wondering how i would enter that days date in a new column in history table for each of those orders so i can tell when order was made???

any help would be great.




Replies:
Posted By: Gullanian
Date Posted: 16 November 2003 at 2:05pm

Well put a date/time column in your database, then your insert query should be something like:

([date]) VALUES ('" & now() & "')



Posted By: hack_it
Date Posted: 16 November 2003 at 2:10pm

INSERT INTO orders_history (ProductID, ProductName, Price, CardNumber, CardType, Expires) SELECT productid, productname, price, cardnumber, cardtype, expires  FROM orders

my insert statement is like this so is there a way of using the values clause as well as the select clause in an insert statement??



Posted By: ljamal
Date Posted: 16 November 2003 at 2:24pm
INSERT INTO orders_history (ProductID, ProductName, Price, CardNumber, CardType, Expires, [datefield]) SELECT productid, productname, price, cardnumber, cardtype, expires, [datefunction] FROM orders

[datefield] is the field that you want the date value in
[datefunction] is the date function (Now() for Access; getdate() for SQL Server)

You could also set the defautl value for the [datefield] with the [datefunction] so that when a new value is entered into the table the value is already present.



-------------
L. Jamal Walton

http://www.ljamal.com/" rel="nofollow - L. Jamal Inc : Web/ Print Design and ASP Programming


Posted By: hack_it
Date Posted: 16 November 2003 at 2:36pm

INSERT INTO orders_history (ProductID, ProductName, Price, CardNumber, CardType, Expires, [OrderDate]) SELECT productid, productname, price, cardnumber, cardtype, expires, [Now()] FROM orders

sorry but is this how its done cause it gives me an error saying too few parameters.




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net