Movatterモバイル変換


[0]ホーム

URL:


Menu
×
See More 
Sign In
+1 Get Certified Upgrade Teachers Spaces Get Certified Upgrade Teachers Spaces
   ❮     
     ❯   

SQL Tutorial

SQL HOMESQL IntroSQL SyntaxSQL SelectSQL Select DistinctSQL WhereSQL Order BySQL AndSQL OrSQL NotSQL Insert IntoSQL Null ValuesSQL UpdateSQL DeleteSQL Select TopSQL Aggregate FunctionsSQL Min and MaxSQL CountSQL SumSQL AvgSQL LikeSQL WildcardsSQL InSQL BetweenSQL AliasesSQL JoinsSQL Inner JoinSQL Left JoinSQL Right JoinSQL Full JoinSQL Self JoinSQL UnionSQL Union AllSQL Group BySQL HavingSQL ExistsSQL Any, AllSQL Select IntoSQL Insert Into SelectSQL CaseSQL Null FunctionsSQL Stored ProceduresSQL CommentsSQL Operators

SQL Database

SQL Create DBSQL Drop DBSQL Backup DBSQL Create TableSQL Drop TableSQL Alter TableSQL ConstraintsSQL Not NullSQL UniqueSQL Primary KeySQL Foreign KeySQL CheckSQL DefaultSQL IndexSQL Auto IncrementSQL DatesSQL ViewsSQL InjectionSQL HostingSQL Data Types

SQL References

SQL KeywordsMySQL Functions
String Functions:ASCIICHAR_LENGTHCHARACTER_LENGTHCONCATCONCAT_WSFIELDFIND_IN_SETFORMATINSERTINSTRLCASELEFTLENGTHLOCATELOWERLPADLTRIMMIDPOSITIONREPEATREPLACEREVERSERIGHTRPADRTRIMSPACESTRCMPSUBSTRSUBSTRINGSUBSTRING_INDEXTRIMUCASEUPPERNumeric Functions:ABSACOSASINATANATAN2AVGCEILCEILINGCOSCOTCOUNTDEGREESDIVEXPFLOORGREATESTLEASTLNLOGLOG10LOG2MAXMINMODPIPOWPOWERRADIANSRANDROUNDSIGNSINSQRTSUMTANTRUNCATEDate Functions:ADDDATEADDTIMECURDATECURRENT_DATECURRENT_TIMECURRENT_TIMESTAMPCURTIMEDATEDATEDIFFDATE_ADDDATE_FORMATDATE_SUBDAYDAYNAMEDAYOFMONTHDAYOFWEEKDAYOFYEAREXTRACTFROM_DAYSHOURLAST_DAYLOCALTIMELOCALTIMESTAMPMAKEDATEMAKETIMEMICROSECONDMINUTEMONTHMONTHNAMENOWPERIOD_ADDPERIOD_DIFFQUARTERSECONDSEC_TO_TIMESTR_TO_DATESUBDATESUBTIMESYSDATETIMETIME_FORMATTIME_TO_SECTIMEDIFFTIMESTAMPTO_DAYSWEEKWEEKDAYWEEKOFYEARYEARYEARWEEKAdvanced Functions:BINBINARYCASECASTCOALESCECONNECTION_IDCONVCONVERTCURRENT_USERDATABASEIFIFNULLISNULLLAST_INSERT_IDNULLIFSESSION_USERSYSTEM_USERUSERVERSION
SQL Server FunctionsMS Access FunctionsSQL Quick Ref

SQL Examples

SQL ExamplesSQL EditorSQL QuizSQL ExercisesSQL ServerSQL SyllabusSQL Study PlanSQL BootcampSQL CertificateSQL Training

SQL ServerFunctions


SQL Server has many built-in functions.

This reference contains string, numeric, date, conversion, and some advanced functions in SQL Server.


SQL Server String Functions

FunctionDescription
ASCIIReturns the ASCII value for the specific character
CHARReturns the character based on the ASCII code
CHARINDEXReturns the position of a substring in a string
CONCATAdds two or more strings together
Concat with +Adds two or more strings together
CONCAT_WSAdds two or more strings together with a separator
DATALENGTHReturns the number of bytes used to represent an expression
DIFFERENCECompares two SOUNDEX values, and returns an integer value
FORMATFormats a value with the specified format
LEFTExtracts a number of characters from a string (starting from left)
LENReturns the length of a string
LOWERConverts a string to lower-case
LTRIMRemoves leading spaces from a string
NCHARReturns the Unicode character based on the number code
PATINDEXReturns the position of a pattern in a string
QUOTENAMEReturns a Unicode string with delimiters added to make the string a valid SQL Server delimited identifier
REPLACEReplaces all occurrences of a substring within a string, with a new substring
REPLICATERepeats a string a specified number of times
REVERSEReverses a string and returns the result
RIGHTExtracts a number of characters from a string (starting from right)
RTRIMRemoves trailing spaces from a string
SOUNDEXReturns a four-character code to evaluate the similarity of two strings
SPACEReturns a string of the specified number of space characters
STRReturns a number as string
STUFFDeletes a part of a string and then inserts another part into the string, starting at a specified position
SUBSTRINGExtracts some characters from a string
TRANSLATEReturns the string from the first argument after the characters specified in the second argument are translated into the characters specified in the third argument.
TRIMRemoves leading and trailing spaces (or other specified characters) from a string
UNICODEReturns the Unicode value for the first character of the input expression
UPPERConverts a string to upper-case


SQL Server Math/Numeric Functions

FunctionDescription
ABSReturns the absolute value of a number
ACOSReturns the arc cosine of a number
ASINReturns the arc sine of a number
ATANReturns the arc tangent of a number
ATN2Returns the arc tangent of two numbers
AVGReturns the average value of an expression
CEILINGReturns the smallest integer value that is >= a number
COUNTReturns the number of records returned by a select query
COSReturns the cosine of a number
COTReturns the cotangent of a number
DEGREESConverts a value in radians to degrees
EXPReturns e raised to the power of a specified number
FLOORReturns the largest integer value that is <= to a number
LOGReturns the natural logarithm of a number, or the logarithm of a number to a specified base
LOG10Returns the natural logarithm of a number to base 10
MAXReturns the maximum value in a set of values
MINReturns the minimum value in a set of values
PIReturns the value of PI
POWERReturns the value of a number raised to the power of another number
RADIANSConverts a degree value into radians
RANDReturns a random number
ROUNDRounds a number to a specified number of decimal places
SIGNReturns the sign of a number
SINReturns the sine of a number
SQRTReturns the square root of a number
SQUAREReturns the square of a number
SUMCalculates the sum of a set of values
TANReturns the tangent of a number

SQL Server Date Functions

FunctionDescription
CURRENT_TIMESTAMPReturns the current date and time
DATEADDAdds a time/date interval to a date and then returns the date
DATEDIFFReturns the difference between two dates
DATEFROMPARTSReturns a date from the specified parts (year, month, and day values)
DATENAMEReturns a specified part of a date (as string)
DATEPARTReturns a specified part of a date (as integer)
DAYReturns the day of the month for a specified date
GETDATEReturns the current database system date and time
GETUTCDATEReturns the current database system UTC date and time
ISDATEChecks an expression and returns 1 if it is a valid date, otherwise 0
MONTHReturns the month part for a specified date (a number from 1 to 12)
SYSDATETIMEReturns the date and time of the SQL Server
YEARReturns the year part for a specified date

SQL Server Advanced Functions

FunctionDescription
CASTConverts a value (of any type) into a specified datatype
COALESCEReturns the first non-null value in a list
CONVERTConverts a value (of any type) into a specified datatype
CURRENT_USERReturns the name of the current user in the SQL Server database
IIFReturns a value if a condition is TRUE, or another value if a condition is FALSE
ISNULLReturn a specified value if the expression is NULL, otherwise return the expression
ISNUMERICTests whether an expression is numeric
NULLIFReturns NULL if two expressions are equal
SESSION_USERReturns the name of the current user in the SQL Server database
SESSIONPROPERTYReturns the session settings for a specified option
SYSTEM_USERReturns the login name for the current user
USER_NAMEReturns the database user name based on the specified id


×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
sales@w3schools.com

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
help@w3schools.com

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning.
Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness
of all content. While using W3Schools, you agree to have read and accepted ourterms of use,cookies andprivacy policy.

Copyright 1999-2025 by Refsnes Data. All Rights Reserved.W3Schools is Powered by W3.CSS.


[8]ページ先頭

©2009-2025 Movatter.jp