need a stored procedure...............

  • Hello friends can someone get me a stored procedure to delete some data from a table if we give a particular date in the parameter. anything is ok.

  • umm thats fairly generic...

    create procedure USP_DeleteMyData

    @date datetime

    as

    Delete from MyTable where MyDate = @date

    go

  • no that does not work

  • Take this and move it to a procedure:

    DECLARE

    @table VARCHAR(100)

    ,@date VARCHAR(30)

    ,@sql VARCHAR(1000);

    SELECT

    @table = 'mytable'

    ,@date = '1901-01-01';

    SELECT

    @sql = 'DELETE FROM ' + @table + ' WHERE AnyColumn < ''' + @date + '''';

    PRINT (@sql);

    -- EXECUTE (@sql);

    Greets

    Flo

  • so where should be the create procedure statement be. sorry for that but i i totally blank.

  • espanolanthony (10/28/2009)


    no that does not work

    what do you mean it doesnt work??

    i assume you replaced the MyTable with your tablename?

  • espanolanthony (10/28/2009)


    so where should be the create procedure statement be. sorry for that but i i totally blank.

    Look at CREATE PROCEDURE in Books On Line (BOL)

  • Hi

    I really don't think it makes sense that you just get any statements from here you don't understand. Please have a look to CREATE PROCEDURE. You really should know what you are doing (especially if you want to manipulate data).

    Greets

    Flo

Viewing 8 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic. Login to reply