Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. How to get the columns except one

How to get the columns except one

Scheduled Pinned Locked Moved Database
questiontutorial
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    Exceter
    wrote on last edited by
    #1

    is it possible to get the data of table except for one column? that is, if I have a table with column names ID, Name, Address, ... How can I get the data of all columns except for ID column? and, how to get the column names(not the data) ? for table names I found the following: Select * from sysobjects where [type] in ('U')

    M 1 Reply Last reply
    0
    • E Exceter

      is it possible to get the data of table except for one column? that is, if I have a table with column names ID, Name, Address, ... How can I get the data of all columns except for ID column? and, how to get the column names(not the data) ? for table names I found the following: Select * from sysobjects where [type] in ('U')

      M Offline
      M Offline
      Mike Dimmick
      wrote on last edited by
      #2

      Exceter wrote: is it possible to get the data of table except for one column? that is, if I have a table with column names ID, Name, Address, ... How can I get the data of all columns except for ID column? Only by specifying all the columns. Note that using the * operator can be a bit costly, because the server has to enumerate the columns - it's usually better to specify them all anyway. and, how to get the column names(not the data) ? for table names I found the following: Select * from sysobjects where [type] in ('U') See http://msdn.microsoft.com/msdnmag/issues/03/08/CodeGeneration/default.aspx[^] for more details.

      A 1 Reply Last reply
      0
      • M Mike Dimmick

        Exceter wrote: is it possible to get the data of table except for one column? that is, if I have a table with column names ID, Name, Address, ... How can I get the data of all columns except for ID column? Only by specifying all the columns. Note that using the * operator can be a bit costly, because the server has to enumerate the columns - it's usually better to specify them all anyway. and, how to get the column names(not the data) ? for table names I found the following: Select * from sysobjects where [type] in ('U') See http://msdn.microsoft.com/msdnmag/issues/03/08/CodeGeneration/default.aspx[^] for more details.

        A Offline
        A Offline
        Alexander Kojevnikov
        wrote on last edited by
        #3

        Mike Dimmick wrote: How can I get the data of all columns except for ID column? Just want to add that it's a bad practice to use SELECT *. Think what will happen with your code if you rename some of your table columns or reorder them. Alexandre Kojevnikov MCAD charter member Leuven, Belgium

        P 1 Reply Last reply
        0
        • A Alexander Kojevnikov

          Mike Dimmick wrote: How can I get the data of all columns except for ID column? Just want to add that it's a bad practice to use SELECT *. Think what will happen with your code if you rename some of your table columns or reorder them. Alexandre Kojevnikov MCAD charter member Leuven, Belgium

          P Offline
          P Offline
          Philip Patrick
          wrote on last edited by
          #4

          Alexandre Kojevnikov wrote: Think what will happen with your code if you rename some of your table columns or reorder them. So what? If you'll specify all columns in SELECT, you will still need to change your code, then what's the matter? Mike actually pointed the right issue about performance of "*" Philip Patrick Web-site: www.stpworks.com "Two beer or not two beer?" Shakesbeer

          A 1 Reply Last reply
          0
          • P Philip Patrick

            Alexandre Kojevnikov wrote: Think what will happen with your code if you rename some of your table columns or reorder them. So what? If you'll specify all columns in SELECT, you will still need to change your code, then what's the matter? Mike actually pointed the right issue about performance of "*" Philip Patrick Web-site: www.stpworks.com "Two beer or not two beer?" Shakesbeer

            A Offline
            A Offline
            Alexander Kojevnikov
            wrote on last edited by
            #5

            Philip Patrick wrote: you will still need to change your code Exactly. But if you don't use SELECT * you will get errors in your SQL query and will have one more possibility to think about consequences of column renaming and adapt the client code appropriately. With SELECT * you might forget about adapting the client code. And in many cases you won't even see compile-time errors. If you are just reordering columns, you won't have to change anything. Performance is also an important issue of course. Alexandre Kojevnikov MCAD charter member Leuven, Belgium

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups