access|server|sql| Comparison | tips
Background database:[Microsoft Access]And[Microsoft SQL Server]After the replacement, the ASP code should note some of the areas to be modified:
[One] connection problem (for example)[Microsoft Access]Constr =
--Show the first day of this month select DATEADD (Mm,datediff (Mm,0,getdate ()), 0) Select CONVERT (Datetime,convert (VARCHAR (8), GETDATE (), 120) + ' 01 ', 120)--show the last day of this month SELECT DATEADD (Day,-1,convert (Datetime,convert
Yesterday select * from TB where DATEDIFF (day, Time field, GETDATE ()) = 1 Today select * from TB where DATEDIFF (day, Time field, GETDATE ()) = 0 Week SE Lect * from TB where DATEDIFF (week, Time field, GETDATE ()) = 0 Last week select * from TB
I. Basics
1. Description: Create a database
Create Database database-name
2. Description: delete a database.
Drop database dbname
3. Description: Back up SQL Server
--- Create a device for the backup data
Use master
Exec sp_addumpdevice 'disk',
I. Basics
1. Description: Create a database
Create Database database-name
2. Description: delete a database.
Drop database dbname
3. Description: Back up SQL Server
--- Create a device for the backup data
Use master
Exec sp_addumpdevice 'disk',
I. Basics
1. Description: Create a database
Create Database database-name
2. Description: delete a database.
Drop database dbname
3. Description: BackupSQLServer
--- Create a device for the backup data
Use master
Exec sp_addumpdevice
function | function/*
T-sql:17 a date-time related Custom function (UDF), Sunday as the last day of the week, not affected by the @ @DateFirst, language version
are collected or refined from the old articles!
Tips:
(@ @Datefirst + datepart (weekday,
(1) Try catch use--Open the Try Catch featureSetXact_abort onbeginTrybegin Tran Insert intoTableName (ID)Values(1) Commit Tran Print 'commited'EndTrybeginCatchrollback Print 'rolled Back'EndCatch(2) Get the number of days
This article from: http://geodesy.blog.sohu.com/78725967.html
I. Basics
1. Description: Create a databaseCreate Database database-name2. Description: delete a database.Drop database dbname3. Description: Back up SQL Server--- Create a device for the
Generally, you need to obtain the current date and calculate some other dates. For example, your program may need to determine the first or last day of a month. Most of you probably know how to divide a date (year, month, day, and so on ), then,
SQL Server time Date function detailed, SQL Server, time date,1. Current system date, timeSelect GETDATE ()2. DateAdd returns a new datetime value based on adding a period of time to the specified dateExample: Add 2 days to the dateSelect DATEADD
1. String manipulation functionsSuppose @a= ' abc789 '1.charindex returns the starting position of a character or string in another stringCHARINDEX (' B ', @a)--Results: 22.substring returns part of a character, binary, text, or image expression
1. display the first day of the month
Select dateadd (mm, DATEDIFF (mm, 0, getdate (), 0)Select convert (datetime, convert (varchar (8), getdate (),120) + '01', 120)
2. display the last day of the month
Select dateadd (day,-1, convert (datetime,
To operate on time in SQL, You need to master four time functions:Dateadd, datediff, datepart, datename.
Dateadd is to add or subtract a time on a specified date.For example, if you add a 3-day select dateadd (day, 3, '2017-05-06 ') on the
To perform time operations in SQL, You need to master four time functions: dateadd, datediff, datepart, and datename.Dateadd is to add or subtract a time on a specified date.For example, if you add a 3-day select dateadd (day, 3, '2017-05-06 ') on
SQL statement Encyclopedia for Action dates:
1. Show the first day of this month
SELECT DATEADD (Mm,datediff (Mm,0,getdate ()), 0)
Select CONVERT (Datetime,convert (varchar (8), GETDATE (),
120) + ' 01 ', 120)
2. Show the last day of this month
This week: SELECT * FROM table where DATEDIFF (Week,c_calltime,getdate ()) =0--c_calltime as Date fieldThis month: SELECT * FROM table where DATEDIFF (Month,c_calltime,getdate ()) =0--c_calltime as Date fieldThis season: SELECT * from table where
Common date functions
SQL Server time and date function detailed, SQL Server, time, date,
1. Current system date, time
Select GETDATE ()
2. DateAdd returns a new datetime value on the basis of adding a period of time to the specified date
For
Select GETDATE () as ' current date ',Datename (Year,getdate ()) as ' year ',Datename (Month,getdate ()) as ' month ',Datename (Day,getdate ()) as ' Day ',Datename (Dw,getdate ()) as ' Week ',Datename (Week,getdate ()) as ' Week number ',Datename
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.