Problem with my procedure

  • Hi Professional.

    I have a procedure which creates a file with column headings like so

    alter procedure [dbo].[extractnewheadings]

    @importedquery nvarchar(1000)

    as

    begin

    Declare @sCmd varchar(256)

    SET @sCmd = 'echo ' + @importedquery + ' > "C:\inetpub\wwwroot\cleansed\headingsonly.csv"'

    exec master..xp_cmdshell @sCmd, no_output

    end

    exec extractnewheadings 'softwaremanufacturer,productname,productversion,Ldate,licensable'

    it produces an error which I cannot seem to rectify

    Msg 217, Level 16, State 1, Procedure extractnewheadings, Line 11

    Maximum stored procedure, function, trigger, or view nesting level exceeded (limit 32).

    any ideas where I could be going wrong

  • my first guess is that you ar emissing a GO statement;

    you've got the CREATE / ALTER, and then a call of the same proc on the last line...so it calls itself over and over, and i doubt that's what you wanted to do:

    i think this is what you wanted instead:

    alter procedure [dbo].[extractnewheadings]

    @importedquery nvarchar(1000)

    as

    begin

    Declare @sCmd varchar(256)

    SET @sCmd = 'echo ' + @importedquery + ' > "C:\inetpub\wwwroot\cleansed\headingsonly.csv"'

    exec master..xp_cmdshell @sCmd, no_output

    end

    GO

    exec extractnewheadings 'softwaremanufacturer,productname,productversion,Ldate,licensable'

    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!

  • Hi Lowell

    that's worked perfect thanks so much

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

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