日期:2014-05-16 浏览次数:20773 次
IF EXISTS(SELECT NAME FROM sys.objects AS o WHERE NAME = 'sp')
DROP TABLE sp
GO
CREATE TABLE sp(
spid INT ,
pm NVARCHAR(10),
pp NVARCHAR(10),
xh VARCHAR(10)
)
INSERT INTO sp( spid, pm, pp, xh)
SELECT 1 , N'打印机' , N'惠普', 'AAA' union all
SELECT 2 , N'传真机' , N'松下', 'SS' union all
SELECT 3 , N'收音机' , N'德生', '909' union all
SELECT 4 , N'笔记本' , N'戴尔', 'abc'
GO
IF EXISTS(SELECT NAME FROM sys.objects AS o WHERE NAME = 'dlist')
DROP TABLE dlist
GO
CREATE TABLE dlist(did INT , rq DATE , ywlx INT , inout int
)
INSERT INTO dlist
SELECT 901 , '2014-01-01' , 1 , 1 UNION ALL
SELECT 902 , '2014-02-01' , 2 , -1 UNION ALL
SELECT 903 , '2014-03-01' , 1 , -1 UNION ALL
SELECT 904 , '2014-04-01' , 2 , -1
GO
IF EXISTS(SELECT NAME FROM sys.objects AS o WHERE NAME = 'lsz')
DROP TABLE lsz
GO
CREATE TABLE lsz(recid INT , did int , spid INT , si int
)
INSERT INTO lsz
SELECT 1 , 901 , 1, 5 UNION ALL
SELECT 2 , 901 , 2, 5 UNION ALL
SELECT 3 , 901 , 3, 6 UNION ALL
SELECT 4 , 902 , 1, 5 UNION ALL
SELECT 5 , 902 , 2, 3 UNION ALL
SELECT 7 , 903 , 3, 2 UNION ALL
SELECT 9 , 904 , 3,&n