Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/sql-server-2008/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql server 2008 如何创建数据类型唯一的SQLServer?_Sql Server 2008 - Fatal编程技术网

Sql server 2008 如何创建数据类型唯一的SQLServer?

Sql server 2008 如何创建数据类型唯一的SQLServer?,sql-server-2008,Sql Server 2008,我有两张桌子 table test1 { id int identity(1,1), name char(40) primary key } table test2 { id int primary, _test1 int } 我希望_test1是Tbl test1(id)的外键。但是它有错误。我如何做idinttest1unique 在test1 create table test1 ( id int identity unique, name char(40) primary

我有两张桌子

table test1
{
id int identity(1,1),
name char(40) primary key
}

table test2
{
id int primary,
_test1 int
}  
我希望_test1是Tbl test1(id)的外键。但是它有错误。我如何做
id
inttest1
unique

test1

create table test1
(
  id int identity unique,
  name char(40) primary key
)

create table test2
(
  id int primary key,
  _test1 int references test1(id)
)
test1

create table test1
(
  id int identity unique,
  name char(40) primary key
)

create table test2
(
  id int primary key,
  _test1 int references test1(id)
)