USE [test]
GO
/****** Object: StoredProcedure [dbo].[dataRoomm] Script Date: 2016/9/29 17:46:17 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER proc [dbo].[dataRoomm] --数据导入
as
begin
declare @count int,@id int,@c int,@dy int
declare @pages int,@pagesizes int
set @pages=1
set @pagesizes=200
declare @name nvarchar(150),@catd nvarchar(200),@phont nvarchar(200) ,@state nvarchar(200),@number nvarchar(200)
declare rs CURSOR LOCAL SCROLL FOR
select [房号],[业主],[电话],[身份证],[房屋状态],[单元] from
[test].[dbo].[Room] where [房号] not in(select top 0 [房号] from [test].[dbo].[Room] where [单元]=2) and [单元]=2
OPEN rs
FETCH NEXT FROM rs INTO @id,@name,@phont,@catd,@state,@dy
WHILE @@FETCH_STATUS = 0
BEGIN
SELECT @number=[房间名称 1],@name=[客户名称 ] ,@catd=[身份证号 ],@phont=[联系电话 ],@state=[销售状态 1]
FROM [test].[dbo].[type] where [test].[dbo].[type].[dy]=@dy and [test].[dbo].[type].[No ]=@id
UPDATE [test].[dbo].[Room]
SET [业主] = @name
,[电话] = @phont
,[身份证] = @catd
,[房屋状态] = @state
WHERE [房号]=@id and [单元]=@dy
select * from [test].[dbo].[Room] WHERE [房号]=@id and [单元]=@dy
FETCH NEXT FROM rs INTO @id,@name,@phont,@catd,@state,@dy
END
CLOSE rs
end