Write a friend of beginner MS SQL

xiaoxiao2021-03-06  64

Often see someone in some BBSs to ask Access to convert to MS SQL, or write a stored procedure, now the younger brother should write some attention or common syntax to everyone (part of the ASP commonly used function )

-------------------

Access: now ()

MS SQL: getDate ()

-------------------

Access: MID

MS SQL: SUBSTRING (Expression, Start, Length)

Expression - To search for the target, but not using the polymerization function

START-Specifies the start position of the string

Length - Specifies the length of the getting string

-------------------

ASP: INSTR

MS SQL: Charindex (Expression1, Expression2)

The position of the parameter and the ASP INSTR are just opposite

-------------------

ASP: DIM

MS SQL: Declare @variable DataType

Example: Declare @varname varchar (50) Declaration Variable @varname is VARCHAR type, length is 50

-------------------

Value:

Declare @varname varchar (10)

Set @varname = 'this is content'

-------------------

Data type conversion function, such as ASP CSTR, CLNG

MS SQL: CAST (Expression As DataType)

Expression is the target object

DataType is the data type to be converted.

Example:

Declare @varname varchar (20) - Declare a @varname variable is VARCHAR type, length 20

Set @varname = '2' - assigns @varname

Cast (@varname as int) - Convert into int type data

-------------------

String connection symbol:

-------------------

cycle:

While boolean_expression

Begin

- To execute the statement

End

Boolean_expression is a Boolean expression, as long as the designated condition is true, loop execution statement

-------------------

IF usage

IF (boolean_expression)

Begin

- Execute True branch ....

End

IF .... else ...

IF (boolean_expression)

Begin

- Execute True branch ....

End

Else

Begin

- Execute a False branch

End

-------------------

转载请注明原文地址:https://www.9cbs.com/read-112539.html

New Post(0)