What is Difference between Function and Stored Procedure?

UDF can be used in the SQL statements anywhere in the  WHERE/HAVING/SELECT section where as Stored procedures cannot be. UDFs  that return tables can be treated as another row-set. This can be used in  Join’s with other tables. Inline UDF’s can be thought of as views that  take parameters and can be used in Join’s and other Row-set operations. Functions are compiled and executed at run time. Stored procedures are stored in parsed and compiled format in the database. Functions cannot affect the state of the database which means we cannot perform insert,delete,update and create operations on the database. Stored … Click here to continue…..

What is De-normalization?

De-normalization is the process of attempting to optimize the  performance of a database by adding redundant data. It is sometimes  necessary because current DBMS’s implement the relational model poorly. A  true relational DBMS would allow for a fully normalized database at the  logical level, while providing physical storage of data that is tuned  for high performance. De-normalization is a technique to move from  higher to lower normal forms of database modeling in order to speed up database access.

What’s the difference between a primary key and a unique key?

Both primary key and unique key enforces uniqueness of the column on which they are defined. But by default primary key creates a clustered index on the column, where are unique creates a nonclustered index by default. Another major difference is that, primary key doesn’t allow NULLs, but unique key allows one NULL only.

What command do we use to rename a db, a table and a column?

To rename db

If someone is using db it will not accept sp_renmaedb. In that case first bring db to single user using sp_dboptions. Use sp_renamedb to rename database. Use sp_dboptions to bring database to multi user mode. E.g.

To rename Table We can change the table name using sp_rename as follows, 

E.g.

To rename Column The script for renaming any column :

E.g.