,一下子就生成了如下的SQL 语句。
-- --------------------------------------------------
-- Entity Designer DDL Script for SQL Server 2005, 2008, and Azure
-- --------------------------------------------------
-- Date Created: 03/24/2012 16:17:11
-- Generated from EDMX file: D:\参考资料\MvcPager源代码和DLL,适合MVC2和MVC3\MvcPager1.5Demo3\Models\Orders.edmx
-- --------------------------------------------------
SET QUOTED_IDENTIFIER OFF;
GO
USE [CiWong_HD];
GO
IF SCHEMA_ID(N'dbo') IS NULL EXECUTE(N'CREATE SCHEMA [dbo]');
GO
-- --------------------------------------------------
-- Dropping existing FOREIGN KEY constraints
-- --------------------------------------------------
-- --------------------------------------------------
-- Dropping existing tables
-- --------------------------------------------------
IF OBJECT_ID(N'[dbo].[Orders]', 'U') IS NOT NULL
DROP TABLE [dbo].[Orders];
GO
-- --------------------------------------------------
-- Creating all tables
-- --------------------------------------------------
-- Creating table 'Orders'
CREATE TABLE [dbo].[Orders] (
[OrderID] int IDENTITY(1,1) NOT NULL,
[CustomerID] nchar(5) NULL,
[EmployeeID] int NULL,
[OrderDate] datetime NULL,
[RequiredDate] datetime NULL,
[ShippedDate] datetime NULL,
[ShipVia] int NULL,
[Freight] decimal(19,4) NULL,
[ShipName] nvarchar(40) NULL,
[ShipAddress] nvarchar(60) NULL,
[ShipCity] nvarchar(15) NULL,
[ShipRegion] nvarchar(15) NULL,
[ShipPostalCode] nvarchar(10) NULL,
[ShipCountry] nvarchar(15) NULL
);
GO
-- --------------------------------------------------
-- Creating all PRIMARY KEY constraints
-- --------------------------------------------------
-- Creating primary key on [OrderID] in table 'Orders'
ALTER TABLE [dbo].[Orders]
ADD CONSTRAINT [PK_Orders]
PRIMARY KEY CLUSTERED ([OrderID] ASC);
GO
-- --------------------------------------------------
-- Creating all FOREIGN KEY constraints
-- --------------------------------------------------
-- --------------------------------------------------
-- Script has ended
-- --------------------------------------------------
循环插入数据
declare @i int;
set @i = 0;
while(@i < 9999)
begin
set @i=@i+1;
insert into dbo.[Orders]
values('n'+CONVERT(nchar(4),@i), @i, GETDATE(), GETDATE(), GETDATE(), @i, 10, N'ShipName'+ CONVERT(nvarchar(20),@i), N'ShipAddress'+ CONVERT(nvarchar(20),@i), N'ShipCity'+ CONVERT(nvarchar(7),@i),N'ShipRegion'+ CONVERT(nvarchar(15),@i),N'Code'+ CONVERT(nvarchar(6),@i),N'Country'+ CONVERT(nvarchar(8),@i))
end
谢谢支持!