Results 1 to 4 of 4
  1. #1
    Join Date
    May 2002
    Location
    Australia
    Posts
    26

    Unanswered: 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
    -----------------

  2. #2
    Join Date
    Feb 2002
    Posts
    2,232
    Why not set the default of the field to getDate() in the table ?

  3. #3
    Join Date
    May 2002
    Location
    Australia
    Posts
    26
    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!

  4. #4
    Join Date
    Nov 2003
    Location
    Christchurch, New Zealand
    Posts
    1,618
    alternatively....

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •