question

rwalker1946 avatar image
rwalker1946 asked

How to retrieve the SQL Comment field from the view properties in the code of a program invb.net.

When a view is created using SSMS and saved then when you try to modify it the properties windows has a field named 'SQL Comment'. Text can be entered into this field and saved. The next time the view is edited the comment field displays the text. I would like to be able to retrieve this field in my VB program. The reason is I am allowing a user to select which view he/she wishes to use. Displaying this comment will allow me to provide the user with some descriptive text about this view.
programming
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Kev Riley avatar image
Kev Riley answered
Doing a bit of testing, I can only find this 'SQL Comment' in the script for the view. So if you right-click and script out the view, whatever you've put as the value of 'SQL Comment' will appear as a block comment (in `/*...*/`) at the top of the view definition. It might not be stored anywhere on it's own - I suspect that when you save the view from the designer, it updates the `definition` value in `sys.sql_modules`, with that comment inline. Some clever string manipulation and you could get it from there I guess?
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.