Table columns

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • netnatter

    #1

    Table columns

    My asp.net pages allow the user to add additional columns to an SQL table

    Is there an SQL statement that I can use to return the number of columns
    that the table currently has?

    Netnatter

  • Alex Meleta

    #2
    Re: Table columns

    Hi netnatter,

    Starting investigation from 'SELECT COUNT(*) FROM <table>' might be a good
    point.

    Regards, Alex Meleta
    [TechBlog] http://devkids.blogspot.com
    My asp.net pages allow the user to add additional columns to an SQL
    table
    >
    Is there an SQL statement that I can use to return the number of
    columns that the table currently has?
    >
    Netnatter
    >

    Comment

    • Mark Rae [MVP]

      #3
      Re: Table columns

      "Alex Meleta" <ameleta@gmail. comwrote in message
      news:df84a49fc4 4c8caf136225d64 d0@news.microso ft.com...
      Starting investigation from 'SELECT COUNT(*) FROM <table>' might be a good
      point.
      How will that help the OP to return the number of *COLUMNS* in his
      datatable...?


      --
      Mark Rae
      ASP.NET MVP


      Comment

      • Mark Rae [MVP]

        #4
        Re: Table columns

        "netnatter" <netnatter@ntlw orld.comwrote in message
        news:TVjEk.5829 2$kM7.37830@new sfe03.ams2...
        Is there an SQL statement that I can use to return the number of columns
        that the table currently has?
        SELECT
        COUNT (*) AS intColumns
        FROM
        sys.tables AS t
        INNER JOIN sys.columns AS c ON t.object_id = c.object_id
        WHERE
        t.name = '<table>'


        --
        Mark Rae
        ASP.NET MVP


        Comment

        • Hans Kesting

          #5
          Re: Table columns

          After serious thinking netnatter wrote :
          My asp.net pages allow the user to add additional columns to an SQL table
          >
          Is there an SQL statement that I can use to return the number of columns that
          the table currently has?
          >
          Netnatter
          SELECT * FROM <tableWHERE 1=0

          this doesn't return any rows, but does return the structure of the
          table. Fill a DataSet with it and you can investigate the Columns.

          Hans Kesting


          Comment

          Working...