Home Database Mysql Tutorial INSERT语法使用技巧一例

INSERT语法使用技巧一例

Jun 07, 2016 pm 03:08 PM
insert server sql skills exist grammar

在SQL Server在线图书(SSBOL)中,请定位sp_dbcmptlevel,然后找出描述6.0、6.5和7.0之间版本兼容性的数据表 。你可以注意到INSERT SQL语句有如下所示的 语法 。 INSERT X SELECT select_list INTO Y 早期的SQL Server数据库(6.0或者6.5版本)可以正确地解

  在SQL Server在线图书(SSBOL)中,请定位sp_dbcmptlevel,然后找出描述6.0、6.5和7.0之间版本兼容性的数据表

  。你可以注意到INSERT SQL语句有如下所示的语法

  INSERT X

  SELECT select_list INTO Y

  早期的SQL Server数据库(6.0或者6.5版本)可以正确地解析这样的语句,但新的SQL Server数据库(7.0 或者8.0版本)就不能正确解析了。虽然语法中的Y 在任何兼容级设置下都不用做插入操作的接收者,但旧的数据库还允许这样的语法存在。这种语法在新的数据库中都因其更严格的语法检查而无法执行,然而,这种"严格要求"却让用户编写的代码更具稳固性。

  以下是一个可以在SQL Server 7.0 或者2000上运行的简单脚本,该脚本说明了以上的语法如何通过旧数据库的测试但却不能通过新数据库的检查。

  SET NOCOUNT OFF

  GO

  USE pubs

  GO

  IF EXISTS (SELECT * FROM sysobjects WHERE type =

  'U' AND name = 'test')

  BEGIN

  DROP TABLE test

  END

  GO

  CREATE TABLE test (col1 INT NULL, col2 INT NULL)

  GO

  EXEC sp_dbcmptlevel pubs, 65

  GO

  INSERT test

  SELECT 1 ,1 INTO y

  GO 862398.com

  EXEC sp_dbcmptlevel pubs, 70

  GO

  INSERT test

  SELECT 2 ,1 INTO y

  GO

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What is the difference between HQL and SQL in Hibernate framework? What is the difference between HQL and SQL in Hibernate framework? Apr 17, 2024 pm 02:57 PM

What is the difference between HQL and SQL in Hibernate framework?

Usage of division operation in Oracle SQL Usage of division operation in Oracle SQL Mar 10, 2024 pm 03:06 PM

Usage of division operation in Oracle SQL

What does the identity attribute in SQL mean? What does the identity attribute in SQL mean? Feb 19, 2024 am 11:24 AM

What does the identity attribute in SQL mean?

Comparison and differences of SQL syntax between Oracle and DB2 Comparison and differences of SQL syntax between Oracle and DB2 Mar 11, 2024 pm 12:09 PM

Comparison and differences of SQL syntax between Oracle and DB2

Detailed explanation of the Set tag function in MyBatis dynamic SQL tags Detailed explanation of the Set tag function in MyBatis dynamic SQL tags Feb 26, 2024 pm 07:48 PM

Detailed explanation of the Set tag function in MyBatis dynamic SQL tags

How to solve the 5120 error in SQL How to solve the 5120 error in SQL Mar 06, 2024 pm 04:33 PM

How to solve the 5120 error in SQL

How to install, uninstall, and reset Windows server backup How to install, uninstall, and reset Windows server backup Mar 06, 2024 am 10:37 AM

How to install, uninstall, and reset Windows server backup

Database technology competition: What are the differences between Oracle and SQL? Database technology competition: What are the differences between Oracle and SQL? Mar 09, 2024 am 08:30 AM

Database technology competition: What are the differences between Oracle and SQL?

See all articles