sql tips

Sometimes we need to know the table structure information of a database. We need to know the information like columns name, data type, length etc. There are multiple options to find the information. Some of them are

sp_columns: You can execute sp_columns and get the columns information of the table.
Example: exec sp_columns ‘Table Name’

sp_help: You can execute sp_help and get the all the necessary information of the table.
Example: exec sp_help ‘Table Name’

Sometimes we do very ugly thing just because of missing simple tricks.
I believe all of the devs who work with sql use SELECT TOP command as they need. This is a very simple sql command.


Now, sometimes you need to use variable instead of constant number (say 10). If you write the query as

In many scenarios we write triggers on database tables. Before writing a trigger we need to understand what trigger is and how exactly it works. Because, lack of clear knowledge on triggers can ake your life difficult. Trigger is actually a procedure that runs in response of an event fired due to performing some operations on database tables. The events could be insert, update or delete. Now, the question is how database handles the execution of a trigger when it fires?

Subscribe to RSS - sql tips