Access转成Sql 2008步骤,同时解决自动编号问题,主键,id数值不
1.开始-Microsoft SQL Server 2008-导入和导出数据(32 位) 2.选择数据源,数据源里选择Microsoft Access,浏览选mdb文件,下一步。 3.选择目标,数据库点新建,名称自定,下一步。 4.复制一个或多个表或视图的数据,下一步。 5.选择源表和源视图,全勾选,选
1.开始->Microsoft SQL Server 2008->导入和导出数据(32 位)
2.选择数据源,数据源里选择Microsoft Access,浏览选mdb文件,下一步。
3.选择目标,数据库点新建,名称自定,下一步。
4.复制一个或多个表或视图的数据,下一步。
5.选择源表和源视图,全勾选,选第一个表,点编辑映射;
出现列映射框,点击编辑SQL,
弹出SQL语句编辑框
在[ID] int NOT NULL,中间加入IDENTITY(1,1),后显示为:[ID] int IDENTITY(1,1) NOT NULL,
确定,确定,回到选择源表和源视图框,继续修改其它表,完成后,下一步。
6.立即运行,下一步。
7.完成。
最后用SQL Server Management Studio连接数据库查看刚转换的数据中的表,ID列。
标识为True,标识种子为1,标识增量为1,
以后添加数据就跟Access里的自动编号效果一样了。
补充:关于主键设置,可以第5步:[ID] int IDENTITY(1,1) NOT NULL, 里插入:Primary key,语句为:
[ID] int Primary key IDENTITY(1,1) NOT NULL,
最后,如果要复制来的id数据不重置(转换后id重新从1来编号),可以勾选第5步列表映射框里:启用标识插入。
====ACCESS转SQLSERVER后代码需要修改的语句=====
1,对于日期字段字段
access表示为:#1981-28-12#
SQLSERVER2000表示为:‘‘1981-02-12‘‘
2,SQL语句区别,select ,update 在对单表操作时都差不多,
但多表操作时update语句的区别ACCESS与SQLSERVER中的Update语句对比:
SQLSERVER中更新多表的Update语句:
Update Tab1
SET a.Name = b.Name FROM Tab1 a,Tab2 b Where a.ID = b.ID;
同样功能的SQL语句在ACCESS中应该是
Update Tab1 a,Tab2 b SET a.Name = b.Name Where a.ID = b.ID;
即:ACCESS中的Update语句没有FROM子句,所有引用的表都列在Update关键字后.
更新单表时:都为:
Update table1 set ab=‘12‘,cd=444 where ....
3,delete语句
access中删除时用:delete * from table1 where a>2 即只要把select 语句里的select 换成delete就可以了。
sqlserve 中则为: delete from table1 where a>2 即没有*号
4,as 后面的计算字段区别
access中可以这样:select a,sum(num) as kc_num,kc_num*num as all_kc_num 即可以把AS后的字段当作一个数据库字段参与计算。
sqlserver 中则为:select a,sum(num) as kc_num,sum(num)*num as all_kc_num 即不可以把AS后的字段当作一个数据库字段参与计算。
5,[.]与[!]的区别
access中多表联合查询时:select tab1!a as tab1a,tab2!b tab2b from tab1,tab2 ,中间的AS可以不要。
sqlserve 中则:select tab1.a as tab1a,tab2.b tab2b from tab1,tab2 ,中间的AS可以不要。
6,联合查询时,
access中多表联合查询:‘select a,b from(
select a,b from tab1 where a>3 union select c,d from tab2 ) group by a,b
sqlserve 中则‘select a,b from(
select a,b from tab1 where a>3 union select c,d from tab2 ) tmptable group by a,b即要加一个虚的表tmptable,表名任意。---
7,access升级到sqlserver时,
可以用sqlserver的数据导入工具导入数据,但要做必要的处理。
access中的自动编号,不会自动转换SQL中的自动编号,只能转换为int型,要把它手工改成标识字段,种子为1,把所有导入被sqlserver转化成的以n开头的字段类型的n去掉,如nvarchar->varchar.把需要有秒类型的日期字段改成datatime类型(SQL会把所有的日期开转化成smalldatetime型)
8,true与1=1
access用where true表示条件为真,
sqlserver用where 1=1表示条件为真
9,判断字段值为空的区别
普通空:
Access和sql server一样 where code is null 或 where code is nol null
条件空:
Access:iif([num] is null,0,[num]) 或 iif([num] is null,[num1],[num])
SQLServer: isnull([num],0) 或 isnull([num],[num1])
10,SQL语句取子串的区别
access:MID(字段,n1,[n2]),LEFT(字段,n),RIGHT(字段,n)
如:select left(cs1,4)+‘-‘+cs2 as cs3
SQLServer: SUBSTRING(expression, start, length)
如:select substring(cs1, 1, 2) + substring(cs1, 4, 2) + ‘-‘ + cs2 as cs3
补充:
ACCESS与SQL2000的SQL语句有区别的
比如now()在SQL2000中必须改为getdate()
还有关键词必须加[] ,像ACCESS中字段名用name SQL20000必须加[name] 否则出错
数据库连接字重新配置
1. access 转sql 数据库后需要建立各表关键字以及递增量设置部分数据类型需要重新定义
2. now() 函数是可接受的,但在日期比较过程中需要用 getdate()
3. 保留字需要加 []
4. 单双引号需要转变
5. 遵循标准sql定义(最关键的一条)
看看MSSQLServer联机丛书。
1.ACCESS的数据库中的自动编号类型在转化时,sql server并没有将它设为自动编号型,我们需在SQL创建语句中加上identity,表示自动编号!
2.转化时,跟日期有关的字段,SQL SERVER默认为smalldatetime型,我们最好将它变为datetime型,因为datetime型的范围比smalldatetime型大。我遇见这种情况,用smalldatetime型时,转化失败,而用datetime型时,转化成功。
3.对此两种数据库进行操作的sql语句不全相同,例如:在对ACCESS数据库进行删除纪录时用:"delete * from user where id=10",而对SQL SERVER数据库进行删除是用:"delete user where id=10".
4.日期函数不相同,在对ACCESS数据库处理中,可用date()、time()等函数,但对
SQL SERVER数据库处理中,只能用datediff,dateadd等函数,而不能用date()、time()等函数。
5.在对ACCESS数据库处理中,sql语句中直接可以用一些VB的函数,像cstr()函数,而对SQL SERVER数据库处理中,却不能用。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

How to configure Zend in Apache? The steps to configure Zend Framework in an Apache Web Server are as follows: Install Zend Framework and extract it into the Web Server directory. Create a .htaccess file. Create the Zend application directory and add the index.php file. Configure the Zend application (application.ini). Restart the Apache Web server.

The key to PHPMyAdmin security defense strategy is: 1. Use the latest version of PHPMyAdmin and regularly update PHP and MySQL; 2. Strictly control access rights, use .htaccess or web server access control; 3. Enable strong password and two-factor authentication; 4. Back up the database regularly; 5. Carefully check the configuration files to avoid exposing sensitive information; 6. Use Web Application Firewall (WAF); 7. Carry out security audits. These measures can effectively reduce the security risks caused by PHPMyAdmin due to improper configuration, over-old version or environmental security risks, and ensure the security of the database.

This article will explain how to improve website performance by analyzing Apache logs under the Debian system. 1. Log Analysis Basics Apache log records the detailed information of all HTTP requests, including IP address, timestamp, request URL, HTTP method and response code. In Debian systems, these logs are usually located in the /var/log/apache2/access.log and /var/log/apache2/error.log directories. Understanding the log structure is the first step in effective analysis. 2. Log analysis tool You can use a variety of tools to analyze Apache logs: Command line tools: grep, awk, sed and other command line tools.

Apache server is a powerful web server software that acts as a bridge between browsers and website servers. 1. It handles HTTP requests and returns web page content based on requests; 2. Modular design allows extended functions, such as support for SSL encryption and dynamic web pages; 3. Configuration files (such as virtual host configurations) need to be carefully set to avoid security vulnerabilities, and optimize performance parameters, such as thread count and timeout time, in order to build high-performance and secure web applications.

This article describes how to effectively monitor the SSL performance of Nginx servers on Debian systems. We will use NginxExporter to export Nginx status data to Prometheus and then visually display it through Grafana. Step 1: Configuring Nginx First, we need to enable the stub_status module in the Nginx configuration file to obtain the status information of Nginx. Add the following snippet in your Nginx configuration file (usually located in /etc/nginx/nginx.conf or its include file): location/nginx_status{stub_status

VprocesserazrabotkiveB-enclosed, Мнепришлостольностьсясзадачейтерациигооглапидляпапакробоглесхетсigootrive. LEAVALLYSUMBALLANCEFRIABLANCEFAUMDOPTOMATIFICATION, ČtookazaLovnetakProsto, Kakaožidal.Posenesko

Nginx performance monitoring and troubleshooting are mainly carried out through the following steps: 1. Use nginx-V to view version information, and enable the stub_status module to monitor the number of active connections, requests and cache hit rate; 2. Use top command to monitor system resource occupation, iostat and vmstat monitor disk I/O and memory usage respectively; 3. Use tcpdump to capture packets to analyze network traffic and troubleshoot network connection problems; 4. Properly configure the number of worker processes to avoid insufficient concurrent processing capabilities or excessive process context switching overhead; 5. Correctly configure Nginx cache to avoid improper cache size settings; 6. By analyzing Nginx logs, such as using awk and grep commands or ELK

This article describes how to customize Apache's log format on Debian systems. The following steps will guide you through the configuration process: Step 1: Access the Apache configuration file The main Apache configuration file of the Debian system is usually located in /etc/apache2/apache2.conf or /etc/apache2/httpd.conf. Open the configuration file with root permissions using the following command: sudonano/etc/apache2/apache2.conf or sudonano/etc/apache2/httpd.conf Step 2: Define custom log formats to find or
