Considerations for transferring Access to MSSqlServer

Source: Internet
Author: User
Tags mssql server
1. to automatically add fields, rewrite them. The automatically numbered field that is frequently used in access. After being imported to mssql, it is not an auto-incrementing int and needs to be set manually, change "no" of the Imported Automatic number field to "yes", and "Seed" and "incremental" to "1" to be automatically numbered. 2. All default values are lost. Mainly

1. to automatically add fields, rewrite them. The automatically numbered field that is frequently used in access. After being imported to mssql, it is not an auto-incrementing int and needs to be set manually, change "no" of the Imported Automatic number field to "yes", and "Seed" and "incremental" to "1" to be automatically numbered. 2. All default values are lost. Mainly

1. to automatically add fields, rewrite them. The automatically numbered field that is frequently used in access. After being imported to mssql, it is not an auto-incrementing int and needs to be set manually, change "no" of the Imported Automatic number field to "yes", and "Seed" and "incremental" to "1" to be automatically numbered.
2. All default values are lost. Mainly numeric and date types
3. Change all now (), time (), date () to getdate ()
4. Change all datediff ('D', time1, time2) to datediff (day, time1, time2)
5. Change all datediff ('ww ', time1, time2) to datediff (week, time1, time2)
6. Change all datediff ('D', time1, time2) to datediff (day, time1, time2)
7. There are many Reserved Words in mssql server that are not available in access. When you import data to mssql, the problem arises. Mssql automatically adds "[field name]" to these fields (including the table names in the database) during import. Therefore, you must modify your script, add the corresponding field name (or table name) in brackets, or change the field name to a reserved word not in mssql.
8. When using access, you like to use SQL statements such as "select * from aaaa while time =" & now () ". However, in mssql, the function "now ()" is not used, but "getdate ()" is used. Therefore, "now ()" In all SQL statements must be replaced with "getdate ()".
9. date functions are different. functions such as date () and time () can be used in ACCESS database processing,
In SQL SERVER database processing, only functions such as datediff and dateadd can be used, instead of functions such as date () and time.
10. For date-related fields during conversion, SQL SERVER is of the smalldatetime type by default. We 'd better convert it to the datetime type because the range of the datetime type is larger than that of the smalldatetime type. Sometimes, if the smalldatetime type is used, the conversion fails. If the datetime type is used, the conversion is successful.
11. Change isnull (rowname) to rowname = null.
12. Change CursorType to 1, that is, when you open the database, the first numeric parameter must be set to 1. Otherwise, the record may be incomplete.
13. Use cast (column as varchar) as the comment type.
14. The true/false type cannot be used. The value must be set to 1/0.
15. The SQL statements used to perform operations on the two databases are not the same. For example, when deleting a record on the ACCESS database, use: "delete * from user where id = 10 ", to delete an SQL SERVER database, use: "delete user where id = 10 ".
16. In ACCESS database processing, some VB functions can be used in SQL statements, such as cstr () functions, but not in SQL SERVER database processing.
17. When you use variable query in the time in the access SQL statement, you generally use "select * from aaaa while time = #" & variable name &"#", in mssql, the syntax is "select * from aaaa while time = '" & variable name &"'"". (This means that you can use the date and time variable as a string)
18. "Delete * FROM…" In asp ......" To change to "Delete FROM ......"
19. It is possible that rs. update fails. modify it to the update table name set field = 'value '.
20. "\" or "/" can be used for Division in access. "/" can only be used in MSSQL "/"
21. Create a primary key in SqlServer
22. If you have any questions, use rs. open SQL, conn, 3, and 2.

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.