Showing posts with label T-SQL Query. Show all posts
Showing posts with label T-SQL Query. Show all posts

Find SQL Column Not Start with Number or Numeric

If you want to find SQL Column that dose not start with Numbers of Numeric here is the Query.


Select Address From Corporation
where Address  Not LIKE '[0-9]%';





If you want to find SQL Column that start with Numbers of Numeric here is the Query.

Select Address from Corporation
where Address  LIKE '[0-9]%';


Find Non Integer From SQL Column

If you want to find Non-Integer from Column in SQL Server  that does not have Data Type integer , Use following SQL Query.




Select *  From [ChildRegistration]
    Where IsNumeric(ChildID + '.0e0') = 0



If you want to find Integer from Column in SQL Server  that does not have Data Type integer , Use following SQL Query.



Select *  From [ChildRegistration]
    Where IsNumeric(ChildID + '.0e0') = 1

Add Identity Column and Populate Column in SQL Server

Add Column using SQL Statment and Populate Identity Column in SQL Server

Alter Table ChildRegistration
Add RegistrationID  Int Identity(1000000,10)

1000000 Means Value Start with 1000000 and adding in 10 increment.

Find Non Date in Column using IsDate

Suppose We have Employee Table with Hiring Date and HiringDate is with Data Type Nvarchar.
We want to find out which one is non date in Hiring Column ?



Find Non-Date Part from Column using SQL Query IsDate


Select * from Employee
Where IsDate(JoiningDate) = 0


Find Date Part from Column using SQL Query IsDate

Select * from Employee
Where IsDate(JoiningDate) = 1




Add Calculated Column Age

Add Calculated Age Column in SQL Server through Query

Alter table Child_Record

Add Age AS (datediff(year,[BirthDate],getdate() ))