• I'll ask a different way:

    when i create a stored procedure, i only want it to get data from the database it exists in.

    It is incredibly rare that i create a procedure that gets data from a different database. if the two queries you posted existed int he database "prod", for example, then the OTHER databases "bpcssql" and "icg" must also exist on the same server...i'm betting they do not exist.

    the queries you posted as an example referend to database outside of the database the procedure exists in...it might be that you want to change them: ie:

    set @SQL = 'select top 10 * from bpcssql.dbo.itemmasternew_bpcs' -->>'select top 10 * from itemmasternew_bpcsand

    --set @SQL = 'execute icg.dbo.SP_MM_ITEMSTATUS ' + '''' + @muusid + '''' -->>'execute SP_MM_ITEMSTATUS

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!