日期:2014-05-17 浏览次数:20450 次
CREATE TABLE [dbo].[emp1](
[code] [nvarchar](50) NOT NULL,
[name] [nvarchar](50) NULL,
[jsr] [nvarchar](50) NULL,
CONSTRAINT [PK_tab1] PRIMARY KEY CLUSTERED
(
[code] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
CREATE TABLE [dbo].[sale1](
[id] [int] IDENTITY(1,1) NOT NULL,
[code] [nvarchar](50) NULL,
[moth] [nvarchar](50) NULL,
[qnt] [float] NULL,
CONSTRAINT [PK_sale1] PRIMARY KEY CLUSTERED
(
[id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
INSERT INTO emp1 (code, name,jsr)
SELECT 'A','A','' UNION ALL
SELECT 'B','B','A' UNION ALL
SELECT 'C','C','A' UNION ALL
SELECT 'D','D','A' UNION ALL
SELECT 'M','M','B' UNION ALL
SELECT 'N','N','B' UNION ALL
SELECT 'R','R','C' UNION ALL
SELECT 'P','P','C' UNION ALL
SELECT 'Q','Q','C'
INSERT INTO sale1 (code, qnt)
SELECT 'A',2000 UNION ALL
SELECT 'B',2000 UNION ALL
SELECT 'C',2000 UNION ALL
SELECT 'D',2000 UNION ALL
SELECT 'M',2000 UNION ALL
SELECT 'N',2000 UNION ALL
SELECT 'R',2000 UNION ALL
SELECT 'P',2000 UNION ALL
SELECT 'Q',2000