Suhail Kaleem » SQL » Page 2

SQL

Add 1 day to GETDATE()

1

GETDATE() function t-sql is used to get current systemdate and time

if you want to add 1 day to GETDATE() this is how you do it

select * from table where ProgrameDate >= Convert(VarChar(10), DATEADD(day, -1, GETDATE()), 101)

you can use DATEDIFF to subtract date from current date

the following table from MSDN lists functions available for datetime in t-sql

Function Determinism
DATEADD Deterministic
DATEDIFF Deterministic
DATENAME Nondeterministic
DATEPART Deterministic except when used as DATEPART (dw,date) or DATEPART (wk,ww, date ). dw, the weekday datepart, depends on the value that is set by SET DATEFIRST, which sets the first day of the week. The week (wk, ww) datepart reflects changes that are made to SET DATEFIRST. January 1 of any year defines the starting number for the week datepart, for example: DATEPART(wk,Jan 1, xxxx) = 1, where xxxx is any year.
DAY Deterministic
GETDATE Nondeterministic
GETUTCDATE Nondeterministic
MONTH Deterministic
YEAR Deterministic

MS SQL File for Countries , US States and All Cities in US

2

For a project i needed a list of countries states of US and then cities of each state, i could not find any single resource  that matched my requirements so i complied a list my self it took me few hours .  the MS SQL script provided will create three tables

1 – Countries
2 – States
3 – Cities

Deleting countries will delete all states and cities related to that country and if a state is deleted all cities related to the state will also be deleted

Download SQL for MS SQL : locations.zip

Delete a large number of records in t-sql

0
TRUNCATE TABLE [tablename]

Truncating will remove all records from the table without logging each deletion.

Go to Top