Scenario:You are working as SQL Server developer with a Bank. They have Dbo.Customer table in TechBrothersIT database with below definition.
Create Table dbo.Customer (FirstName VARCHAR(50) Not Null, LastName VARCHAR(50), Age SmallInt, PhoneNumber CHAR(9), DOB Date, Gender CHAR(1) )As you noticed that LastName can be Null. That is the problem. Company noticed that later and always want to have the value for LastName. You are asked to do analysis and write Alter script to Change Column from Null to Not Null. What things you will consider or suggestions you will provide?
Select * From dbo.Customer where LastName Is null
update dbo.Customer set LastName='' where LastName is Null
Alter Table dbo.Customer Alter Column LastName VARCHAR(50) Not Null