Search This Blog

Select * vs Select Columns Names From Table in SQL

             Select * vs Select Columns Names From Table

People often write Select * while fetching Records from table but in fact it's not a good practise

Below are Points that will tell why you should not fetch records using Select * from table


1-Selecting * will fetch all columns name  which in result use more resources, more network and slower queries.

2-Secondly if someone alters the structure of your table SELECT * will suddenly start bringing back a structure you weren't expecting.

3-Fetching all Records using Select * prohibits the query from using Covered Indexes.

4- SELECT * reduces your ability to do research on which columns are used as only the ones in JOIN, WHERE, GROUP BY, and ORDER BY (assuming you aren't silly enough to use the SELECT list position #s) clauses will show up when doing searches. If you need to rename or drop a column you need to be able to determine EVERYWHERE it is being used.

5-SELECT * instead of SELECT field1, field2 then you will also get field3 which you don't need / want but it will be sent over the network to the application so for every row it will have unnecessary transport of field 3.


 If you are lazy enough  for writing column names in query  then use SSMS

Right Click Table Name-Script Table as-Select to- New Query Editor Window.
It will give you all column names remove columns which is not required:

Below is the procedure of Generating Script of a table along with all Column Names.


8 comments:

  1. Pretty good post. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog posts. Any way I’ll be subscribing to your feed and I hope you post again soon. Wye Strainer

    ReplyDelete
  2. hello!! Very interesting discussion glad that I came across such informative post. Keep up the good work friend. Glad to be part of your net community. Vancouver SEO Agency

    ReplyDelete
  3. I wanted to thank you for this excellent read!! I definitely loved every little bit of it. I have you bookmarked your site to check out the new stuff you post. Europa-Road nemzetközi szállítmányozás Szeged

    ReplyDelete
  4. Very informative post! There is a lot of information here that can help any business get started with a successful social networking campaign. Europa-Road Kft.

    ReplyDelete
  5. Along these lines, on the off chance that you need to err on the side of caution, you might need to recruit the administrations of an expert drywallers.io The temporary worker will do the whole activity for you without committing expensive errors and making a ton of wreck.

    ReplyDelete
  6. Your blog is too much amazing. I have found with ease what I was looking. Moreover, the content quality is awesome. Thanks for the nudge! nemzetközi áruszállítás Europa-Road Kft.

    ReplyDelete
  7. Great post, you have pointed out some fantastic points , I likewise think this s a very wonderful website. we buy Milwaukee houses

    ReplyDelete