Microsoft SQL Server
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsDatabaseMicrosoft SQL Server

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old March 29th, 2005, 06:37 PM
GEM1204 GEM1204 is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Location: Texas
Posts: 169 GEM1204 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 9 h 36 m 57 sec
Reputation Power: 5
Comments in views and procedures

I am new to sql server and thought it was great that you were able to comment what you were doing when writing sql. I was using query analyzer to work out some of my sql. I even learned how to use the if and case statements creating comments to explain what I was doing. The question is after all of that work of commenting as I went was lost when I saved it as a view, and I also lost all the comments when I tried saving is as a stored procedure. What’s the point of comments if they don’t get saved with the view or sp. Am I missing something? Is there a way to save all your comments that you make when creating stored procedures or views? I also tried to indent like you do in VB and keep everything lined up to. I lost all that too.



Thanks

Reply With Quote
  #2  
Old March 29th, 2005, 08:39 PM
Memnoch's Avatar
Memnoch Memnoch is offline
Unholy Moderator
ASP Free God 14th Plane (11500 - 11999 posts)
 
Join Date: Oct 2003
Location: In hell, where did you think?
Posts: 11,776 Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 3 Weeks 5 Days 8 h 27 m 42 sec
Reputation Power: 470
comments don't get saved in views, but your comments should still exist in the stored procedure.

Example:
Code:
/*
This procedure gets all the records from the Person table.
*/
CREATE PROCEDURE stp_SELECT_Get_All_People
AS
SELECT *
FROM Person

The text between the /* and */ are the comments.
I'm not sure how you saved your code to a stored procedure, but writing this way will always save your comments.

Reply With Quote
  #3  
Old March 31st, 2005, 06:40 PM
GEM1204 GEM1204 is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Location: Texas
Posts: 169 GEM1204 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 9 h 36 m 57 sec
Reputation Power: 5
Thanx Mennoch RE: Comments in stored procedure

Thanks Mennoch…. I did my homework
You were right about comments in stored procedures. If you create a stored procedure using the Create or Alter procedure statement all comments will be saved. I was using an Access project where you can open the stored procedures in a GUI query design view for procedures where the sql can be graphically displayed. The procedure will initially open with all the comments showing in the sql window, but if you make any changes to that procedure by using the GUI interface instead of just entering the sql, some or all of the comments are moved to the top of the procedure before the alter statement. Depending on how may changes you make using GUI determines how many of the comments are saved - I guess.

As far as Views with comments, the view won't be graphically displayed in the design view of enterprise manager and you still can't see the comments even in the sql window. If you script the object in query analyzer the comments are there! In an Access project you can open the same view and it will be graphically displayed but without the comments. If you make any changes to the view in the Access GUI the same thing happens as with procedures - some or all or none of the comments are moved before the Alter statement if you script the view.

If I can do the same thing in both, which would be better to use a query or a view? The sp or view would be used for an MS Access reports database and would return about 10,000 rows but filters would be applied to the reports based on the user's input. The view or SP would have one case statement and several date computations with 17 fields returned.

I already know I can just apply a filter to a view which would be easy, but If I use an sp I'll have to deal with parameters. What would be more effective?

Thanks

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseMicrosoft SQL Server > Comments in views and procedures


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT