How to use sql defined functions as fields?

送分小仙女□ 提交于 2019-12-20 04:28:20

问题


I am creating tables in Sql Management Studio 2012 using SQL. How do I make fields or columns with names that are already defined in Sql Server e.g User_ID, User_Name. I want to use them as fields in my tables.

Table definition from Duplicate Post:

create table Ticket(
  Ticket_Id varchar(10) not null,
  TicketType_Id varchar(3) not null,
  Ticket_PurchaseDate DateTime null,
  LottoDraw_Id int null,
  User_Id int null,
  Ticket_IsWinner bit null
  Primary Key(Ticket_Id,TicketType_Id)
)

回答1:


Warp the column name like in brackets [ ] ... such as

create table Ticket(
  Ticket_Id varchar(10) not null,
  TicketType_Id varchar(3) not null,
  Ticket_PurchaseDate DateTime null,
  LottoDraw_Id int null,
  [User_Id] int null,
  Ticket_IsWinner bit null
  Primary Key(Ticket_Id,TicketType_Id)
)


来源:https://stackoverflow.com/questions/30151478/how-to-use-sql-defined-functions-as-fields

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!