随笔分类 - SQL Servr
摘要:create table Cart( [UserID] uniqueidentifier not null, [ProductID] int not null, [ProductName] varchar(80) not null, [Price] [decimal](10, 2) NOT NULL, [ImagePath] [varchar](100) NULL, Quantity int not null, IsAnonymous bit not null)alter table Cartadd constraint [PK_Cart] primary key CLUSTERED([USe
阅读全文
摘要:转自 http://www.cnblogs.com/nokiaguy/archive/2009/02/05/1384860.htm 先看下面一个嵌套的查询语句:select*from person.StateProvincewhere CountryRegionCodein (select CountryRegionCodefrom person.CountryRegionwhere Name like'C%') 上面的查询语句使用了一个子查询。虽然这条SQL语句并不复杂,但如果嵌套的层次过多,会使SQL语句非常难以阅读和维护。因此,也可以使用表变量的方式来解决这个问题,SQL
阅读全文
摘要:SQL Server 2005没有直接生成表内容的脚本功能需要手动实现View Code CREATE PROCEDURE dbo.UspOutputData @tablename sysname AS BEGIN declare @column varchar(1000) declare @columndata varchar(1000) declare @sql varchar(4000) declare @xtype tinyint declare @name sysname declare @...
阅读全文