SQL server 2008 创建主键为自增列的表
使用Tranact-SQL 编写代码来创建一个新表:
USE [OnlineJudge]
GO
/****** Object: Table [dbo].[User1] Script Date: 05/17/2010 14:05:06 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[User2](/*notice convert the tablename*/
[num] [int]IDENTITY(1,1) NOT NULL,
[userid] [nchar](10) NOT NULL,
[password] [nchar](10) NOT NULL,
[authority] [int] NOT NULL,
[logintime] [datetime] NOT NULL,
CONSTRAINT [PK_User2] PRIMARY KEY CLUSTERED /*notice convert the tablename*/
(
[num] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
相关文档:
--语 句 功 能
--数据操作
SELECT --从数据库表中检索数据行和列
INSERT --向数据库表添加新数据行
DELETE --从数据库表中删除数据行
UPDATE --更新数据库表中的数据
--数据定义
CREATE TABLE --创建一个数据库表
DROP TABLE --从数据库中删除表
......
ASP.NET如何连接Access或SQL Server数据库
首先看一个例子代码片断:
程序代码:
--------------------------------------------------------------------------------
using System.Data;
using System.Data.OleDb;
......
string strConnection="Provider=Microsoft.Jet.OleDb.4.0;";
strConnection+ ......
Case具有两种格式。简单Case函数和Case搜索函数。
--简单Case函数
CASE sex
WHEN '1' THEN '男'
WHEN '2' THEN '女'
ELSE '其他' END
--Case搜索函数
CASE WHEN sex = '1' THEN '男'
  ......
select *from customers
select *from orders
select customers.cust_id, orders.order_num from customers inner join orders on customers.cust_id=orders.cust_id
select customers.cust_id, orders.order_num from customers left outer join orders on customers.cust_id=orde ......