getting error "“Invalid object name ''SizeMst''. “ " while exec sp

  • Dear All,

    I am using sql2005.

    i am writing stored procedure to save various master data . I recognize master by @type (input verible) and assign it to @mst veriable then based on @mst no I perform saving task . I created sp . now I am trying to execute then I am getting error

    “Invalid object name 'SizeMst'. “ I am running this query from its database.

    Stored perocedure is

    Alter procedure [dbo].[Sp_RestMst_Save]

    @type int ,

    @id varchar(20),

    @shortdesp varchar(50),

    @longdesp varchar(100),

    @userid varchar(50),

    @ipadd varchar(50)

    as

    declare @mst int

    set @mst = @type

    if ( @mst = 1)

    begin ;

    -- saving data in sizemst

    update SizeMst set sshortdesp = @shortdesp , sdesp = @longdesp,smodifiedby = @userid , smodifieddt = getdate() ,ipadd = @ipadd where sizeid = @id;

    if(@@rowcount = 0)

    insert into SizeMst(sizeid,sshortdesp,sdesp,screatedby,screateddt,ipadd) values(@id,@shortdesp,@longdesp,@userid, getdate(),@ipadd);

    end ;

    else

    if(@mst = 2)

    begin ;

    -- saving data in brandMst

    update BrandMst set bshortdesp = @shortdesp ,bdesp = @longdesp, bmodifiedby = @userid , bmodifieddt = getdate() ,ipadd = @ipadd where brandid = @id;

    if(@@rowcount = 0)

    insert into brandMst(brandid,bshortdesp,bdesp,bcreatedby,bcreateddt,ipadd) values(@id,@shortdesp,@longdesp,@userid, getdate(),@ipadd);

    end ;

    else

    if(@mst = 3)

    begin ;

    -- saving data in metalktmst

    update MetalKtMst set mshortdesp = @shortdesp ,mdesp = @longdesp, mmodifiedby = @userid , mmodifieddt = getdate() ,ipadd = @ipadd where metalktid = @id;

    if(@@rowcount = 0)

    insert into MetalKtMst(metalktid,mshortdesp,mdesp,mcreatedby,mcreateddt,ipadd) values(@id,@shortdesp,@longdesp,@userid, getdate(),@ipadd);

    end ;

    Please guide me in doing so or give me some useful link.

    Thanks



    regards

    imran khan

     

  • Stupid questions, I know, but have you checked to make sure that

    1) The table is there

    2) The name is spelt correctly

    3) It's in the dbo schema

    4) If your db is case sensitive, that the case matches.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • checks who owns the stored procedure, you may need to prefix the sp name with the owner, espec if you are not dbo.

    ---------------------------------------------------------------------

  • Just do an select on sys.all_objects to confirm if the object exist then if exist get the object id from that and check what is the schema for that object and call the object with schema.objectname.

    Cheers,
    Sugeshkumar Rajendran
    SQL Server MVP
    http://sugeshkr.blogspot.com

Viewing 4 posts - 1 through 3 (of 3 total)

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