SQL Server Developer Center >
SQL Server Forums
>
SQL Server SMO/DMO
>
StoredProcedureParameter comment
StoredProcedureParameter comment
- Hi,I am currently creating a StoredProcedure using this kind of code:This will generate sql like the folowing:
StoredProcedure storedProcedure = new StoredProcedure(database, name); StoredProcedureParameter storedProcedureParameter = new StoredProcedureParameter(storedProcedure, parameterName, t.VariantType); storedProcedure.Parameters.Add(storedProcedureParameter);
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] AS
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
- 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.- Marked As Answer byCalinoiu Alexandru Monday, November 09, 2009 6:49 AM
All Replies
- 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.- Marked As Answer byCalinoiu Alexandru Monday, November 09, 2009 6:49 AM
Hi,
Thank you
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.
"ME: How do I achive the imposible !" "The Wise Man: With entusiams !"


