如何从设定的编号开始对Azure DW中的行进行唯一编号 [英] How to uniquely number rows in Azure DW starting from a set number

查看:142
本文介绍了如何从设定的编号开始对Azure DW中的行进行唯一编号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello DW Gurus,

Hello DW Gurus,

我遇到了另一种在SQL Server中运行良好的技术,但是在与行编号有关的SQL Azure DW上却中断了.

I've run into another technique that works fine in SQL Server, but breaks on SQL Azure DW that has to do with numbering rows.

假设有一个不带id列的TableA.以下过程适用于SQL:

Assume there's a TableA that was created without id column. The following procedure works on SQL:

-查询#1以添加新列:
ALTER TABLE表A添加newIDColumn INT

-查询#2以播种起始ID值,然后更新表以对从100开始的新id列编号:
声明@newID INT
SELECT @newID = 100

更新TableA
SET @newID = newIDColumn = @newID +1

--Query #1 to add new column:
ALTER TABLE TableA ADD newIDColumn INT

--Query #2 to seed the starting ID value and then update the table to number the new id column starting at 100:
DECLARE @newID INT
SELECT @newID = 100

UPDATE TableA
SET @newID = newIDColumn = @newID + 1

不幸的是,在Azure DW中,这在最后一条语句上失败,错误为msg:

Unfortunately, in Azure DW this fails on the last statement with the error msg:

在第2行,第10列分析错误:'('附近的语法不正确.

Parse error at line: 2, column: 10: Incorrect syntax near '('.

非常奇怪,因为该语句甚至都没有偏执!

Very strange, since the statement doesn't even contain a paranthesis!

对在Azure SQL DW中可以使用的类似技术有何建议?

ANy suggestions for a similar technique that works in Azure SQL DW?

MK_RP

推荐答案

Hello,

https://docs.microsoft.com/zh-CN/azure/sql-data-warehouse/sql-data-warehouse-tables-identity


Regards,

Alberto Morillo
SQLCoffee.com


这篇关于如何从设定的编号开始对Azure DW中的行进行唯一编号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆