Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    Join Date
    Oct 2006
    Posts
    83

    Thumbs down Unanswered: comment in column definition

    Plesae tell me the MSSQL Server equivalent of the below MySQL query .

    create table temp2(a varchar(23) comment 'male m');

    What is the use of specifying a keyword 'comment' in the column definition. Will it make any difference
    Last edited by krReddy; 04-30-07 at 11:19.

  2. #2
    Join Date
    Jan 2003
    Location
    Massachusetts
    Posts
    5,800
    Provided Answers: 11
    That create table statement does not work in SQL Server. What RDBMS are you using?

  3. #3
    Join Date
    Oct 2006
    Posts
    83
    Sorry , the above SQL Query is in MySQL Syntax . Could you please tell me the equivalent in MSSQL Server.

  4. #4
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Is comment setting a default?
    Testimonial:
    pootle flump
    ur codings are working excelent.

  5. #5
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Actually it looks more like SPSS value labels or the like. If so - no- you need to set up another table and establish a foreign key.
    Testimonial:
    pootle flump
    ur codings are working excelent.

  6. #6
    Join Date
    Dec 2002
    Posts
    1,245
    I'm guessing that you are trying to add a comment to your column to indicate what it is for. Depending on your version of SQL Server, you will have to use a separate syntax:

    SQL 2000
    Code:
    sp_addextendedproperty 'Caption', 'US Phone Number',
                           'user', dbo, 'table', TestExProp, 'column', USPhoneNmbr

    SQL 2005:
    Code:
    EXEC sys.sp_addextendedproperty 
    @name = N'MS_DescriptionExample', 
    @value = N'Minimum inventory quantity.', 
    @level0type = N'SCHEMA', @level0name = Production, 
    @level1type = N'TABLE',  @level1name = Product,
    @level2type = N'COLUMN', @level2name = SafetyStockLevel;
    GO

    Regards,

    hmscott
    Have you hugged your backup today?

  7. #7
    Join Date
    May 2004
    Location
    Seattle
    Posts
    1,313
    I think the 2000 syntax works on 2005 as well actually, for backwards compatibility.

  8. #8
    Join Date
    Dec 2002
    Posts
    1,245
    Quote Originally Posted by jezemine
    I think the 2000 syntax works on 2005 as well actually, for backwards compatibility.
    prolly, but no sense in making it easy for him...



    hmscott
    Have you hugged your backup today?

  9. #9
    Join Date
    May 2004
    Location
    Seattle
    Posts
    1,313
    in that case you should have given him the 2007 syntax.

  10. #10
    Join Date
    Dec 2002
    Posts
    1,245
    Quote Originally Posted by jezemine
    in that case you should have given him the 2007 syntax.
    That's the new "virtual" syntax. You just think about it and it appears...



    hmscott
    Have you hugged your backup today?

  11. #11
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    FYI:
    http://www.dbforums.com/showthread.p...44#post6270444

    Thanks for trying to find out krReddy
    Testimonial:
    pootle flump
    ur codings are working excelent.

  12. #12
    Join Date
    Oct 2006
    Posts
    83

    Thumbs down comment lines un create table syntax

    I am creating a table in SQL Server using the below query.

    CREATE TABLE temp(
    type21 varchar(1) default NULL /*where the COMMENT will be saved'*/)
    In the above query there is a comment line enclosed in /* and */ .
    This query is executable .

    Please tell me where will this comment line be saved in SQL Server database .

    I have checked this in SYSCOMMENTS but i didn't found .

    If it is saved some where in the database , Plz tell me the query to fetch that comment

    Thanks

  13. #13
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Syscomments is something else entirly. You know that the stuff /* here */ is commented out (a different sort of meaning for comment) and as such does not get executed. It is not stored anywhere. As far as SQL Server is concerned it does not exist - it is for the coders use only.
    Last edited by pootle flump; 05-02-07 at 11:07.
    Testimonial:
    pootle flump
    ur codings are working excelent.

  14. #14
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by krReddy
    If it is saved some where in the database ...
    it isn't
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  15. #15
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Quote Originally Posted by r937
    it isn't
    Sigh - if only I could be so concise.

    Why use twenty words when two\ three will do.

    Indeed - why write all that at all?
    Testimonial:
    pootle flump
    ur codings are working excelent.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •