April 9, 2015 at 9:50 pm
Hello,
I’m wondering if you could please help me.
I’m wanting a SQL Formula to insert into my Accounting Systems which uses a SQL Database which, when I add a new product code I want a custom field to update with today’s date.
I’ve tried to use GetDate () however, what this does is to update all records with this date (each record has this custom field assign to it). I only want the new record to show todays date so I know when the product was created in the database. Should I be looking at creating this with a Function?
April 9, 2015 at 10:37 pm
Sounds like you tried to run an update query without a filter. You shouldn't need one. Something like this should work.
CREATE PROC uspInsertRecord
@ProductCode VARCHAR(10)
AS
BEGIN
INSERT INTO MyTable(ProductCode, SomeDateField)
VALUES (@ProductCode,GETDATE())
END
April 9, 2015 at 10:45 pm
Hello, thanks for your reply.
When I add a new product in my accounting software and select Save & Close, I want a custom field (ZDateopened) in the database to be updated by SQL in the background to populate this field.
This is needed for a client who wants it automatic.
The table name is called PRODUCTS
April 10, 2015 at 12:50 am
Add default constraint on column ZDateopened with getdate() function.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply