|
Notes for converting access to SQL To add fields automatically, 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 the "no" of the Imported Automatic number field to "yes", and the "Seed" and "incremental" are both "1" to be automatically numbered. All default values are lost. Mainly numeric and date types All now (), time (), date () must be changed to getdate () Change all datediff ('D', time1, time2) to datediff (day, time1, time2) Change all datediff ('ww ', time1, time2) to datediff (Week, time1, time2) Change all datediff ('D', time1, time2) to datediff (day, time1, time2) In MSSQL Server, there are many reserved words that are not available in access. When you import data to MSSQL, the problem arises. When MSSQL imports these fields (Including the table name in the database) and "[field name]", you must modify your script and enclose the corresponding field name (or table name) with brackets, or change the field name to be not guaranteed by MSSQL. Reserved Words When using access, you like to use "select * From AAAA while For SQL statements such as time = "& now ()", however, "Now ()" is not used in MSSQL, but "getdate ()" is used. Therefore, all In the SQL statement, "Now ()" must be replaced with "getdate ()". The date functions are different. In the ACCESS database processing, functions such as date () and time () are available, In SQL Server database processing, only functions such as datediff and dateadd can be used, instead of functions such as date () and time. Transfer For date-related fields, 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. Large. Sometimes, if the smalldatetime type is used, the conversion fails. If the datetime type is used, the conversion is successful. Change isnull (rowname) to rowname = NULL The value of cursortype must be changed to 1, that is, when the database is opened, the first numeric parameter must be set to 1. Otherwise, the record may Incomplete display The remarks type should be used by cast (column as varchar ). The value of true or false type cannot be used. The value must be set to 1/0. The SQL statements used to operate these two databases are not all the same. For example, when you delete a record in an Access database, use: "delete * from user where id = 10 ", to delete an SQL Server database, use: "delete user where id = 10 ". In the process of Access database, some VB functions can be used in SQL statements, such as the CSTR () function, but cannot be used in the process of SQL Server database. In access When the time in the SQL statement is queried using variables, you generally use "select * From AAAA while Time = # "& variable name &" # ", which cannot be used in MSSQL. Its syntax is" select * From AAAA while Time = '"& variable name &"'"". (This means that you can use the date and time variables as strings ~~~) The original "delete * from..." In ASP ......" To change to "delete from ......" It is possible that Rs. Update fails and is changed to the update table name set field = 'value'. (in this case, the prompt is: Microsoft ole db provider for SQL Server Error '80040e38' Optimistic concurrency check failed. This row has been modified beyond this cursor. /Admin_classorder.asp, row 164) The Division in access can be "or"/". Only"/"can be used in MSSQL "/" 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, In MSSQL Server, there are many reserved words that are not available in access. When you import data to MSSQL, the problem arises. When MSSQL imports these fields (Including the table name in the database) and "[field name]", you must modify your script and enclose the corresponding field name (or table name) with brackets, or change the field name to be not guaranteed by MSSQL. Reserved Words 8. When using access for time usage, you like to use "select * From AAAA while For SQL statements such as time = "& now ()", however, "Now ()" is not used in MSSQL, but "getdate ()" is used. Therefore, all In the SQL statement, "Now ()" 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, 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. Large. 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 all the same. For example, when deleting a record on the Access database, use: "delete * from user where Id = 10 ", while the SQL Server database is deleted using:" 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 a variable to query the time in an access SQL statement, you generally use "select * From AAAA while Time = # "& variable name &" # ", which cannot be used in MSSQL. Its 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. Use Rs. Open SQL, Conn, 3, 2, or 3, 1 if any problem persists. |