Bizzare sp_makewebtask issue

  • I'm getting a bizzare error when I execute makewebtask. If I execute the bolded commented out @SQL I get the following failure:

    Server: Msg 16805, Level 11, State 1, Procedure sp_makewebtask, Line 131

    SQL Web Assistant: Could not execute the SQL statement.

    But if I use the select statement instead of the stored procedure, it executes perfectly.

    A little history, I'm a SA, so thats not the issue. I used the PRINT key word to make sure the stored procedure I'm executing inside @Query actually works, and it does. We also just recently migrated from SQL 2000 to 2005. The stored procedure was created in 2000. Has anyone seen anything like this before?

    Working on this bit of code below:

    DECLARE @muusid varchar(50)

    declare @Reptitle varchar(500)

    declare @SQL varchar(1000)

    set @muusid = '#CAELS1'

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

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

    print @SQL

    set @Reptitle = 'Mass Maintenance Status Report for ' + ltrim(rtrim(@muusid))

    EXECUTE sp_makewebtask

    @outputfile = 'y:\ftp\HtmlReports\MM_QUE_#CAELS1.htm'

    ,@query = @SQL

    ,@webpagetitle = 'MASS MAINTENANCE'

    ,@resultstitle = @Reptitle

    ,@dbname = 'ICG'

  • I've got two ideas to look at:

    one is related to cross database chaining:

    one command points to one database, and the other points to a different one ...which is correct?

    set @muusid = '#CAELS1'

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

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

    the other thing is are you sure the stored procedure has SET NOCOUNT ON at the top?

    you can get wierd results like you are describing if the store proc will return results, but doesn't have that command at the top.

    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!

  • I tried both of those methods and they both failed. the Set NoCount On was specified and I called both SQL statements from the same database. What I did find though, was that if I executed a stored procedure that passed no parameters in the @QUERY, then it worked fine, but I tested a few other stored procedures that did require a parameter to be passed and they all failed. Does anyone know why this might be? Was something set up improperly maybe when we migrated to the new server. This procedure was never an issue in 2000.

    Thanks!

  • 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!

  • They are all on the same server, we just ported everything in the same schema to 2005. I already used a select statement with the ICG database and it worked fine. Like I found, it is only when you pass a parameter into the stored procedure you're executing in the @Query statement. It does this no matter which database you're executing against.

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

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