Results 1 to 5 of 5

Thread: What's wrong with this Stored Procedure

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Aug 2002
    Posts
    20

    Question What's wrong with this Stored Procedure

    I am getting the errors:

    Msg 208, Sev 16: Invalid object name 'Archive_VTWINTABLE'. [SQLSTATE 42S02]
    Msg 208, Sev 16: Invalid object name 'VTWINTABLE'. [SQLSTATE 42S02]

    I checked my tables names and they match the names in the stored procedure.



    CREATE PROCEDURE [p_Archive_VTWINTABLE]
    AS
    Declare @dateCurrentDate datetime
    Declare @dblCutoffDays float
    Declare @strCutOffDate varchar(11)
    Declare @dateCutOffDate datetime

    Select @dateCurrentDate = GetDate()
    Select @dblCutOffDays = 8 * -1 -- 8 equates to the number of days to keep records in short
    Select @strCutOffDate = DateAdd(d, @dblCutOffDays, @dateCurrentDate)
    Select @dateCutOffDate = Convert(DateTime, @strCutOffDate)

    INSERT INTO Archive_VTWINTABLE SELECT * FROM VTWINTABLE where
    RecDate < @dateCutOffDate

    Delete VTWINTABLE from VTWINTABLE where
    RecDate < @dateCutOffDate
    GO

  2. #2
    Frenzied Member Memnoch1207's Avatar
    Join Date
    Feb 2002
    Location
    DUH, Guess...Hint: It's really hot!
    Posts
    1,861
    it doesn't recognize the names...try putting either [] around them or if the names are actually capitalized...try putting quotes around them.
    Being educated does not make you intelligent.

    Need a weekend getaway??? Come Visit

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Aug 2002
    Posts
    20

    No go!

    Tried quotes and brackets and still same error.

  4. #4
    Hyperactive Member Granty's Avatar
    Join Date
    Mar 2001
    Location
    London
    Posts
    439
    As a check try using the full path of the tables:

    [ServerName].[DatabaseName].owner.[TableName]

    Hard to help on this one as we cant see your server

  5. #5
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687
    Two things come to mind....
    1) Try specifying the actual field names in the insert...
    2) The delete is wrong...
    Delete from VTWINTABLE where
    RecDate < @dateCutOffDate

    It's just Delete From (tbl name)..... not Delete X From (tbl name)....
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

Posting Permissions

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



Click Here to Expand Forum to Full Width