--- to Add New Column in Table---
ALTER TABLE dbo.[{Table Name}] add [{Column Name}] Nvarchar Null
--- to DELETE Column from data Table---
ALTER TABLE [{Table Name}] DROP COLUMN [{Column Name}];
--ALTER COLUMN data TYPE---
ALTER TABLE [dbo].[{Table Name}] ALTER COLUMN [{Column Name}] Data-type Null
--- Rename Column name in data Table---
exec sp_rename '[{Table Name}].[{Column Name}]','New Column Name','COLUMN'
---****You can easily change the column name without recreating the table or losing ur records.
---Tools---
-----> Options
--> Designers
--> Table and database designers
--> Uncheck
-->Prevent saving changes that required table re-creation.
Cast([Receipt Date] as date)'Date'
---****You can easily change the column name without recreating the table or losing ur records.
---Tools---
-----> Options
--> Designers
--> Table and database designers
--> Uncheck
-->Prevent saving changes that required table re-creation.
Cast([Receipt Date] as date)'Date'
--Return '2021-12-17'
------- Add days into current date for future date or past Date
Select DATEAdd(DAY,10, Cast(Getdate() as date)) 'Day 10 Added'
Select DATEAdd(Month,-3, Cast(Getdate() as date)) 'Previous 3 Month'
Select DATEAdd(YEAR,1, Cast(Getdate() as date)) 'Year 1 Added'
----Day of Year(Number)
Select DATEPART(DAYOFYEAR, Getdate())
----Day of Week
Select DATEName(WEEKDAY, Getdate())
Select DATEName(DW, Getdate())
-----date difference
select DATEDIFF(day,'1983-03-14',Getdate()) 'Days Count'
select DATEDIFF(yy,'1983-03-14',Getdate()) 'Year'
---'Start date of last 4 Month'
Select DATEAdd(Month,-4, cast(Getdate()-Day(Getdate())+1 as date)) 'Start date of last 4 Month'
---'First date End Date of the Month'
Select cast(Getdate()-Day(Getdate())+1 as date) 'Start date of the Month'
Select EOMONTH(Getdate()) 'End date of the Month'
-----Replace Foumula
Cast([Receipt Date] as Time)'Time'
--Return '14:03:24' ------- Add days into current date for future date or past Date
Select DATEAdd(DAY,10, Cast(Getdate() as date)) 'Day 10 Added'
Select DATEAdd(Month,-3, Cast(Getdate() as date)) 'Previous 3 Month'
Select DATEAdd(YEAR,1, Cast(Getdate() as date)) 'Year 1 Added'
----Day of Year(Number)
Select DATEPART(DAYOFYEAR, Getdate())
----Day of Week
Select DATEName(WEEKDAY, Getdate())
Select DATEName(DW, Getdate())
-----date difference
select DATEDIFF(day,'1983-03-14',Getdate()) 'Days Count'
select DATEDIFF(yy,'1983-03-14',Getdate()) 'Year'
---'Start date of last 4 Month'
Select DATEAdd(Month,-4, cast(Getdate()-Day(Getdate())+1 as date)) 'Start date of last 4 Month'
---'First date End Date of the Month'
Select cast(Getdate()-Day(Getdate())+1 as date) 'Start date of the Month'
Select EOMONTH(Getdate()) 'End date of the Month'
-----Replace Foumula
Replace([Column Name],'{Removing Part of String}','{New Part to add in String}')
