AZURE SQL DWH-CREATE TABLE语法-DATE列-DEFAULT getdate()-不支持 [英] AZURE SQL DWH - CREATE TABLE syntax - DATE column - DEFAULT getdate() - NOT SUPPORTED

查看:81
本文介绍了AZURE SQL DWH-CREATE TABLE语法-DATE列-DEFAULT getdate()-不支持的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

     

   我在尝试 此

    I am trying this 

创建表T1(C1日期时间默认为getdate()

我收到如下错误消息.

讯息104338,第16级,状态1,第15行
表达式不能与默认约束一起使用.仅为默认约束指定常量.

CREATE TABLE T1 (C1 Datetime default getdate()

I am getting Error message like below.

Msg 104338, Level 16, State 1, Line 15
An expression cannot be used with a default constraint. Specify only constants for a default constraint.

需要帮助....谢谢!!!!

Need help....Thank you!!!!!

推荐答案

嗨Vasudsv,

Hi Vasudsv,

您可以使用当前时间(Transact-SQL). 获取日期 (Transact-SQL)对Azure SQL数据仓库也有效.两者都以datetime格式返回值,这是默认表达式.您需要为表名称使用常量. 您的问题采用声明的格式.请参见以下堆栈溢出线程:  更改列,添加默认约束

You can use CURRENT_TIMESTAMP (Transact-SQL). GETDATE (Transact-SQL) is also valid for Azure SQL Data Warehouse. Both return the value in datetime format, which is the default expression. You need to use a constant for a table name. Your issue is in the format of the statement. Please see this Stack Overflow thread: Alter column, add default constraint

获取表达式,然后将table更改为该表达式的名称.我希望这会有所帮助.

Get the expression and then alter table as the name of that expression. I hope this helps.

此致

迈克


这篇关于AZURE SQL DWH-CREATE TABLE语法-DATE列-DEFAULT getdate()-不支持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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