SQL 2008 VS 2012错误: Incorrect syntax near the keyword 'COMPUTE'

标签 sql sql-server sql-server-2008 tsql sql-server-2012

我的 friend 向我发送了他在服务器 2008 中编写的命令,它们运行没有问题,但是我的副本和过去的命令在 2012 中不起作用。有什么原因吗?这是代码:

        Use Kudler_Database
        SELECT  AccountNumber, [Description], ShortDescription,Balance
        FROM Chart_of_Accounts 
        ORDER BY left (AccountNumber, 2)
        COMPUTE SUM(Balance) BY left (AccountNumber, 2)
        COMPUTE SUM(Balance); 

这是错误:

Msg 156, Level 15, State 1, Line 6 Incorrect syntax near the keyword 'COMPUTE'.

最佳答案

COMPUTE 在 SQL Server 2012 中不再可用,这就是您收到该错误的原因。请参阅此页:

它说:

This topic describes the Database Engine features that are no longer available in SQL Server 2012:

*Transact-SQL syntax | COMPUTE / COMPUTE BY *

关于SQL 2008 VS 2012错误: Incorrect syntax near the keyword 'COMPUTE' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12491404/

相关文章:

SQL Server 超时 - 重试还是更长的超时?

php - 更新彼此链接的三个表时出现问题

Sql Server 2008计算两个日期之间的夜晚但删除第31晚

mysql - 相当于 sql server 中表 information_schema.tables 中的 MYSQL AUTO_INCREMENT 列

asp.net - 恢复SQL Server 2008数据库后"Invalid object name"

sql - 选择查询固定长度

android - 查询 "cont"列上最大值的行

SQLite 在 INSERT 和 UPDATE 时自动递增

asp.net - 使用域用户的 SQL 连接字符串?

ruby-on-rails-3 - Ruby on Rails 与 Sql Server(不兼容的字符编码 : UTF-8 and ASCII-8BIT)