数据库结构
USE [suiwogou]
GO
/****** 对象: Table [dbo].[S_City] 脚本日期: 05/05/2011 14:57:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[S_City](
[CityID] [bigint] NOT NULL,
[CityName] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[ZipCode] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[ProvinceID] [bigint] NULL
) ON [PRIMARY]
遍历每一行的CityName
declare @CityName varchar(50)
declare cursors cursor
for
select CityName from S_City
open cursors
fetch next from cursors into @CityName
while (@@fetch_status = 0)
begin
print @CityName
fetch next from cursors into @CityName
end
close cursors
deallocate cursors