Syntax differences between ASP + ACCESS and MS SQL

Source: Internet
Author: User

Http://www.pconline.com.cn/pcjob/other/data/mcdba/0409/456571.html

Often on some BBs saw someone asking access to convert to ms SQL what to pay attention to, or writing stored procedures, now, I want to write some notes or common syntaxes here for your reference (some are common ASP functions)

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

Access: Now ()

Ms SQL: getdate ()

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

Access: Mid

SQL MS: substring (expression, start, length)
Expression-target to be searched, but cannot use aggregate Functions
Start-specify the start position of the string
Length-specify the length of the obtained string

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

ASP: instr

Ms SQL: charindex (expression1, expression2)
The parameter is in the opposite position as the ASP instr.

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

ASP: dim

Ms SQL: declare @ variable datatype
For example, declare @ varname varchar (50) declares that the variable @ varname is of the varchar type and the length is 50.

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

Assignment:
Declare @ varname varchar (10)
Set @ varname = 'this is content'

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

Data type conversion functions, such as asp cstr and 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 variable named @ varname in the varchar type with a length of 20
Set @ varname = '2' -- assign a value to @ varname
Cast (@ varname as INT) -- convert to int type data

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

String Connection Symbol: +

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

Loop:

While boolean_expression
Begin
-- Statement to be executed
End

Boolean_expression is a Boolean expression. If the specified condition is true, statements are executed cyclically.

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

If usage
If (boolean_expression)
Begin
-- Execute true branch ....
End

Usage of IF... else...
If (boolean_expression)
Begin
-- Execute true branch ....
End
Else
Begin
-- Execute the false Branch
End

Related Article

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.