Category Archives: Sql Server Tutorials

How to avoid Select *

It is commonly known that you should not use SELECT * when you are writing a query.
Most of the times, we only need a some of the columns that a table has and we should retrieve only those columns.
This are some of the disadvantages of using Select * :
Continue reading How to avoid Select *

How to get only the date from datetime

I have listed below two solutions for extracting a date from a datetime : Continue reading How to get only the date from datetime

How to delete column that has a foreign key in MsSql

Scenario :  Delete a column that has a foreign key. Continue reading How to delete column that has a foreign key in MsSql

How to create a foreign key in MsSql

Scenario : We have two tables 1 Customers 2 Sales

I have to make sure that all the client id's that are inserted in the Sales table exists in the Client table Continue reading How to create a foreign key in MsSql

How to concatenate a list of names fast and easy in Sql Server

Scenario : We have a table that contains all the employees of our company and we want to take all their names and concatenate them separated by comma. Continue reading How to concatenate a list of names fast and easy in Sql Server