Query To Replace Space Between String

  1. SELCET replace(‘Test String’,’ ‘,”)

TestString

2. DECLARE @Text varchar(1000)

SET @Text = ‘Hi I am John’

SELECT replace(@Text,’ ‘ ,’ ‘)


HiIamJohn

 

Advertisements

REPLACE And STUFF in SQL

REPLACE is used to replace all the occurrences of the given pattern in a string.
Example
SELECT REPLACE(‘Hello i am here’,’H’,’m’)
— mello i am mere

STUFF used to replace the part of string with some other string.
Example
SELECT STUFF(‘Hello i am here’,1,5,’Hi’)
— Hi i am here

Difference between Primary Key and Unique Key

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.

Approach on designing a Database

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.