What is the difference between REPLACE() and STUFF() functions?

REPLACE() It is used to replace all the occurrences of the second argument in the first argument with the third argument. Syntax: REPLACE (String, StringPattern, StringTobeReplaced) Ex: SELECT REPLACE (‘SQLVERSITY is a good website’, ‘good’, ‘great’) Output: SQLVERSITY is a great website STUFF()

Read More

What are ACID properties?

ACID properties The acronym ACID stands for Atomicity, Consistency, Isolation and Durability. These are group of properties that every DBMS must satisfy. Any database is said to be reliable, if it meets all these properties. Otherwise, we consider that DBMS as not reliable.

Read More

How do you rename a table or column name?

Rename The stored procedure sp_rename is used to rename a table or a column name in a table. Syntax: To rename a table name ——————————————————————————————————————– sp_RENAME ‘[PresentTableName]’,‘[NewTableName]’ GO To rename a table column name: sp_RENAME ‘TableName.[PresentColumnName]’,‘[NewColumnName]’,‘COLUMN’ GO Ex: sp_RENAME ‘Mytable’,‘Myrenamedtable’ GO sp_RENAME

Read More

What is meant by the error ‘String or binary data would be truncated. The statement has been terminated’?

String or binary data would be truncated This is the common error in SQL Server when we are inserting or updating the data. When you are get this error for the first time, you will not be in a position to understand

Read More

What is the difference between the basic datatypes Char and Varchar?

Char 1. It is fixed memory allocation. Ex: —————————————————- DECLARE @CharTest CHAR(10) SET @CharTest = ‘ABCD’ SELECT DATALENGTH(@CharTest) —————————————————- Output: 10 —————————————————- 2. Takes more memory space compare to Varchar. 3. Query performance is better. 4. It fills the unused memory space with

Read More

What is RAISERROR ()? Where do you use this?

RAISERROR The name itself RAISERROR is saying that, we are raising an error. Mostly we use this with exceptional handling of stored procedures, SQL scripts. In SQL Server we have ERROR_MESSAGE() function to display error messages. But sometimes it might not give meaningful

Read More

What is the basic difference between different types of Ranking functions?

Ranking functions ROW_NUMBER: It just returns the sequence numbers starts from 1. RANK: Returns the rank of each record in the current result set. DENSE_RANK: It is same as Rank() function. But it returns without gaps in ranking. Do not worry about

Read More

What are the System databases available in SQL Server?

System databases After installing SQL Server in your computer, you will get 4 default databases. Master Model MSDB TempDB For more information about System databases, Click here

Read More

What is the difference between Clustered index & Non Clustered Index?

Clustered Index Data is stored in physical order. The leaf nodes of Clustered indexes will contain actual data. Only one clustered index should exist in a table.  Non-Clustered Index It does not sort the data in physical order. But it will have

Read More

What is the basic difference between DELETE and TRUNCATE commands?

DELETE It is a DML command We can use filters in WHERE clause to delete the data Removes specified data only Deletes one row at a time Records removed data in transaction logs It does not resets the identity field of the

Read More