Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can i create a store procedure to update the date?

Status
Not open for further replies.

luckyguy

Programmer
Nov 22, 2002
8
MY
Im going to create a store procedure to update the "datesale" in a table which called salesorders.My assumption is, the system will update the datesale everytime we enter the salesorders.Therefore,we r not need to type in the datesale...Hope someone can help me...thankx alot!
 
Hi

If you want to use a stored proc then you will either need to execute in your application or create a FOR INSERT TRIGGER that either executes the stored proc or updates the field itself using getdate().

You could avoid all of this code by just adding a default to your date column. The default will automatically set the current system date for the record inserted.

ALTER TABLE yourtable
ADD CONSTRAINT DF_tablename_datesale DEFAULT (getdate()) FOR DATESALE
GO

You can use any name you wish for the DEFAULT but you can't have the same default name being used twice.

Hope this helps.

John
GO
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top