Wednesday, March 7, 2012

returning values in stored proceedures

Helloooooooooooooo,

I've createde a stored proceedure that executes an INSERT.

There is a field [date] and i want to put the current date in there.

This doesn't work but there must be some easy way:
thanks in advance!!!!

-----
CREATE PROCEDURE dbo.sp_InsertSomething
@.something varchar(50),
@.date smalldatetime
AS
-- this is where i get lost
--SELECT getDate() AS mydate
--@.date = mydate

INSERT INTO [dbo].[mytable] (something, [date])
VALUES(
@.something,
@.date
)

GO
------Why not set the default of the field to getDate() in the table ?|||Originally posted by rnealejr
Why not set the default of the field to getDate() in the table ?

oh man that is a really good idea. how dumb am i!|||alternatively...

INSERT INTO [dbo].[mytable] (something, [date])
VALUES(@.something, getDate())

No comments:

Post a Comment