SQL Server Developer Center > SQL Server Forums > SQL Server SMO/DMO > StoredProcedureParameter comment
Ask a questionAsk a question
 

AnswerStoredProcedureParameter comment

  • Friday, November 06, 2009 7:05 AMCalinoiu Alexandru Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Has Code
    Hi,

     I am currently creating a StoredProcedure using this kind of code:

    StoredProcedure storedProcedure = new StoredProcedure(database, name);
    StoredProcedureParameter storedProcedureParameter = new StoredProcedureParameter(storedProcedure, parameterName, t.VariantType);
                                        storedProcedure.Parameters.Add(storedProcedureParameter);
    
    This will generate sql like the folowing:

    SET ANSI_NULLS OFF
    GO
    SET QUOTED_IDENTIFIER OFF
    GO
    ALTER PROCEDURE [dbo].[Book10]
    	@Product [int]
    AS
    
    I want to be able to add comments to the sql parameter, so that the sql code should look like:
    SET ANSI_NULLS OFF
    GO
    SET QUOTED_IDENTIFIER OFF
    GO
    ALTER PROCEDURE [dbo].[Book10]
    	@Product [int] /*comment for firt param */
    AS
    Is there a way to achive this using StoredProcedure and StoredProcedureParameter ?

    Thank you,

    "ME: How do I achive the imposible !" "The Wise Man: With entusiams !"

Answers

  • Sunday, November 08, 2009 9:10 PMAlok Parmesh - MSFTAnswererUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Hi,

    There are two ways to deal with a storedProcedure in SMO.
    1.TextMode off (which you are using right now)
       You provide parameters and all other details required by SMO to generate the header i.e. Alter Procedure .... As
       You cannot provide comments using this way in the header.

    2.TextMode on
       Instead of providing details like parameters etc you provide TextHeader like storedProcedure.TextHeader = "Alter Procedure .... @Product .../* comment */ AS"
       and TextBody which you did in previous way also.
       This way just appends header and body so you can have the comments.

    You can change the textmode using property TextMode on storedprocedure class like storedprocedure.TextMode = true or false

    Regards,
    Alok Parmesh

    Mark Post as helpful if it provides any help.Otherwise,leave it as it is.

All Replies

  • Sunday, November 08, 2009 9:10 PMAlok Parmesh - MSFTAnswererUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Hi,

    There are two ways to deal with a storedProcedure in SMO.
    1.TextMode off (which you are using right now)
       You provide parameters and all other details required by SMO to generate the header i.e. Alter Procedure .... As
       You cannot provide comments using this way in the header.

    2.TextMode on
       Instead of providing details like parameters etc you provide TextHeader like storedProcedure.TextHeader = "Alter Procedure .... @Product .../* comment */ AS"
       and TextBody which you did in previous way also.
       This way just appends header and body so you can have the comments.

    You can change the textmode using property TextMode on storedprocedure class like storedprocedure.TextMode = true or false

    Regards,
    Alok Parmesh

    Mark Post as helpful if it provides any help.Otherwise,leave it as it is.
  • Monday, November 09, 2009 5:08 AMCalinoiu Alexandru Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi,

    There are two ways to deal with a storedProcedure in SMO.
    1.TextMode off (which you are using right now)
       You provide parameters and all other details required by SMO to generate the header i.e. Alter Procedure .... As
       You cannot provide comments using this way in the header.

    2.TextMode on
       Instead of providing details like parameters etc you provide TextHeader like storedProcedure.TextHeader = "Alter Procedure .... @Product .../* comment */ AS"
       and TextBody which you did in previous way also.
       This way just appends header and body so you can have the comments.

    You can change the textmode using property TextMode on storedprocedure class like storedprocedure.TextMode = true or false

    Regards,
    Alok Parmesh

    Mark Post as helpful if it provides any help.Otherwise,leave it as it is.
    Thank you
    "ME: How do I achive the imposible !" "The Wise Man: With entusiams !"