sql mark

  USE [master]
GO

/****** Object:  Table [dbo].[Users]    Script Date: 02/10/2011 23:32:17 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO
IF not EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Users]') AND type in (N'U'))
begin
CREATE TABLE [dbo].[Users](
    [id] [uniqueidentifier] NOT NULL,
    [username] [nvarchar](50) NULL,
    [password] [nvarchar](50) NULL,
    [type] [nvarchar](50) NULL,
 CONSTRAINT [PK_Users] 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]
end
GO

ALTER TABLE [dbo].[Users] ADD  CONSTRAINT [DF_Users_id]  DEFAULT (newid()) FOR [id]
GO
declare @NUM numeric(5,0)
declare @SQLSTR nvarchar(500)
set @NUM = 0
START:
if @NUM>=800
begin
goto FINISH
end
else
begin
 set @NUM+=1
 set @SQLSTR='Insert into [dbo].[Users]
    (
        username,
        [password],
        [type] )
    values(
        ''User'+Convert(nvarchar(5),@NUM)+''',
        ''123'',
        ''2'')'
    exec(@SQLSTR)
print @SQLSTR
print @NUM
 goto START
end

FINISH:

你可能感兴趣的:(sql,mark)