日期:2014-05-16 浏览次数:20642 次
drop table a;
drop table b;
drop table c;
CREATE TABLE a(aid INT PRIMARY KEY,[type] INT,sname NVARCHAR(50))
CREATE TABLE b(bid INT PRIMARY KEY,sname NVARCHAR(50),[rank] INT)
CREATE TABLE c(cid INT IDENTITY(1,1) PRIMARY KEY,[Type] int,sname NVARCHAR(50),objectId int);
GO
INSERT INTO [dbo].[a] ([aid],[type],[sname])
SELECT ((SELECT ISNULL(MAX(ocxa.[aid]),10) FROM a ocxa)+ROW_NUMBER() OVER ( ORDER BY GETDATE())) AS rId
,1,null FROM MASTER.dbo.spt_values sv WHERE sv.[type]='P' AND sv.number<100;
INSERT INTO [dbo].[a] ([aid],[type],[sname])
SELECT ((SELECT ISNULL(MAX(ocxa.[aid]),10) FROM a ocxa)+ROW_NUMBER() OVER ( ORDER BY GETDATE())) AS rId
,2,null FROM MASTER.dbo.spt_values sv WHERE sv.[type]='P' AND sv.number<300;
INSERT INTO [dbo].[a] ([aid],[type],[sname])
SELECT ((SELECT ISNULL(MAX(ocxa.[aid]),10) FROM a ocxa)+ROW_NUMBER() OVER ( ORDER BY GETDATE())) AS rId
,3,null FROM MASTER.dbo.spt_values sv WHERE sv.[type]='P' AND sv.number<500;
INSERT INTO [dbo].[a] ([aid],[type],[sname])
SELECT ((SELECT ISNULL(MAX(ocxa.[aid]),0) FROM a ocxa)+ROW_NUMBER() OVER ( ORDER BY GETDATE())) AS rId
,4,null FROM MASTER.dbo.spt_values sv WHERE sv.[type]='P' AND sv.number<100;
INSERT INTO [dbo].[b] ([bid],[sname],[rank])
SELECT ((SELECT ISNULL(MAX(ocxa.[bid]),0) FROM b ocxa)+ROW_NUMBER() OVER ( ORDER BY GETDATE())) AS rId
,'2_'+ltrim(NEWID()),2 FROM MASTER.dbo.spt_values sv WHERE sv.[type]='P' AND sv.number<20;
INSERT INTO [dbo].[b] ([bid],[sname],[rank])
SELECT ((SELECT ISNULL(MAX(ocxa.[bid]),0) FROM b ocxa)+ROW_NUMBER() OVER ( ORDER BY GETDATE())) AS rId
,'1_'+ltrim(NEWID()),1 FROM MASTER