How to restore database using SQL query in TSQL?

How to restore database using SQL query in TSQL?

If you have a database backup .bak file extension and want to restore it using SQL query. You can use the built-in 'RESTORE DATABASE' function. Remember in order to be able to restore a database successfully. You need to be a database owner which has the role of db_owner. You also need to ensure that there is no open session use the database.
How to get all table sizes in TSQL?

How to get all table sizes in TSQL?

To get the information about how much space or size used by tables. You can retrieve the size information by linking multiple tables in sys tables. There are two tables that hold this information. The first one is the sys.partitions table. You can get the no of rows created of a table. The second will be the sys.allocation_units table which will return the information of used_pages info.
How to generate new Guid in TSQL?

How to generate new Guid in TSQL?

GUID stands for Globally Unique Identifier. It is a universally unique id using a pseudo-random 128 bit number. GUIDs are mostly used to replace as another alternative or replacement of integer value. It is preferable to compare with numbers because it is unique across tables, databases, and servers. The drawback is it contains 4 times larger than the traditional 4-byte index value.
How to add a new column in TSQL?

How to add a new column in TSQL?

If you need to add a new column in TSQL. You need to use the keyword function 'ALTER TABLE'. It is recommended you perform a check if the proposed column you want to add is not already existed in the database table otherwise you will receive an error message.