多表的建立 (一) 表的腳本
搞了好久都沒有搞懂1.2的1對多關系是怎麼建立,後來參照官方api一點一點的試,終于成功了一次.
應為我的網速慢,所以分快加入.
應為我的網速慢,所以分快加入.
1
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[DataZJ]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
2
drop table [dbo].[DataZJ]
3
GO
4![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
5
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[UserZJ]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
6
drop table [dbo].[UserZJ]
7
GO
8![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
9
CREATE TABLE [dbo].[DataZJ] (
10
[Meid] [int] IDENTITY (1, 1) NOT NULL ,
11
[xb] [bigint] NULL ,
12
[sr] [datetime] NULL ,
13
[dz] [varchar] (500) COLLATE Chinese_Taiwan_Stroke_CI_AS NULL
14
) ON [PRIMARY]
15
GO
16![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
17
CREATE TABLE [dbo].[UserZJ] (
18
[id] [int] IDENTITY (1, 1) NOT NULL ,
19
[zname] [varchar] (50) COLLATE Chinese_Taiwan_Stroke_CI_AS NULL ,
20
[Meid] [int] NULL
21
) ON [PRIMARY]
22
GO
23![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
24
ALTER TABLE [dbo].[DataZJ] ADD
25
CONSTRAINT [PK_DataZJ] PRIMARY KEY CLUSTERED
26
(
27
[Meid]
28
) ON [PRIMARY]
29
GO
30![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
31
ALTER TABLE [dbo].[UserZJ] ADD
32
CONSTRAINT [PK_UserZJ] PRIMARY KEY CLUSTERED
33
(
34
[id]
35
) ON [PRIMARY]
36
GO
37![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
38![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
2
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
3
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
4
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
5
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
6
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
7
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
8
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
9
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
10
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
11
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
12
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
13
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
14
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
15
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
16
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
17
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
18
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
19
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
20
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
21
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
22
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
23
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
24
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
25
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
26
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
27
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
28
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
29
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
30
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
31
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
32
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
33
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
34
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
35
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
36
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
37
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
38
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)