REPLACE is used to replace all the occurrences of the given pattern in a string.
SELECT REPLACE(‘Hello i am here’,’H’,’m’)
— mello i am mere
STUFF used to replace the part of string with some other string.
SELECT STUFF(‘Hello i am here’,1,5,’Hi’)
— Hi i am here
A unique key can also be a primary key and can involve in joins.
Differences are: when you create a primary key by default it will create a clustered index whereas for the unique key by default it will create non clustered index.
A table will contains only one primary key in a table, but can contains more than one unique key.
Primary key won’t allow any null value, but unique key allows only one null.
Gather the requirements and create a conceptual model (use case)
and Create a logical model (ER Modeling) from this conceptual model
and implement the physical model (choose RDBMS)(data types, constraints, indexes etc…) from the logical model
and create a prototype of your application and test the model.
Select * from employee where salary in
SELECT TOP 1 salary FROM
SELECT DISTINCT TOP nth salary FROM employee ORDER BY salary DESC
a ORDER BY salary
In principle, they are the same and are handled in the same way by your application. The only difference is that NVARCHAR can handle unicode characters, allowing you to use multiple languages in the database (Arabian, Chinese, etc.). NVARCHAR takes twice as much space when compared to VARCHAR.
Use NVARCHAR only if you are using foreign languages.
VARCHAR stores variable-length character data whose range varies up to 8000 bytes; varchar(MAX) stores variable-length character data whose range may vary beyond 8000 bytes and till 2 GB. TEXT datatype is going to be deprecated in future versions, and the usage of VARCHAR(MAX) is strongly recommended instead of TEXT datatypes.