易截截图软件、单文件、免安装、纯绿色、仅160KB
热门标签: c c# c++ asp asp.net linux php jsp java vb Python Ruby mysql sql access Sqlite sqlserver delphi javascript Oracle ajax wap mssql html css flash flex dreamweaver xml
 最新文章 :

【SQL SERVER2005页面存储3之 聚集索引的存储】


                                                       聚集索引的存储
 
一:聚集索引的叶级别存储
聚集索引在叶级别的存储其实就是以数据页的形式存储的,之前几篇关于堆数据行的存储已经都详细说过了,但是这里因为有了聚集索引,
所以还是有个特殊的地方需要注意的--带有唯一标识符的聚集索引行.
我们如果在建表并为其建立聚集索引时,没有为它指定UNIQUE属性,那么系统在键值遇到重复的时候,会自动增加一个字节的字段来保证聚集键值的唯一。
至于为什么要保证它聚集键值的唯一,那么因为非聚集索引在引用它作为书签的时候必须要征求唯一性来取到唯一行
/*----------------------------------------------------------------------
*auther:Poofly
*date:2010.3.14
*VERSION:
Microsoft SQL Server 2008 (RTM) - 10.0.1600.22&n ......

SQL行转列 列转行


--行列互转
/****************************************************************************************************************************************************** 
以学生成绩为例子,比较形象易懂 整理人:中国风
(Roy) 
日期
:2008.06.06 ******************************************************************************************************************************************************/
 
--1、行互列
--> --> (Roy)
生成測試數據
 
if
 
not
 
object_id
(
'Class'
)
is
 
null
 
drop
 
table
 
Class
 
Go
 
Create
 
table
 
Class(
[Student]
 
nvarchar
(
2
),
[Course]
 
nvarchar
(
2
),
[Score]
 
int
)
Insert
 
Class
 
select
 
N
'张三
'
,N
'语文
'
,
78
 
union
 
all
 
select
 
N
'张三
'
,N
'数学
'
,
87
 
union
 
all
 
select
&nb ......

SQL Server里面如何导出包含数据的SQL脚本

通常情况下,SQL Server里面的生成SQL脚本,只会包含数据库及表的字段结构,而不会包含表的数据,也就是SQL脚本里面只有Create database,Create table 这样的语句,没有insert into。
因为SQL Server并不包含这个功能,只能靠第三方的代码了。
以下存储过程可以实现:
CREATE PROCEDURE dbo.UspOutputData
@tablename sysname
AS
declare @column varchar(1000)
declare @columndata varchar(1000)
declare @sql varchar(4000)
declare @xtype tinyint
declare @name sysname
declare @objectId int
declare @objectname sysname
declare @ident int
set nocount on
set @objectId=object_id(@tablename)
if @objectId is null -- 判断对象是否存在
begin
print 'The object not exists'
return
end
set @objectname=rtrim(object_name(@objectId))
if @objectname is null or charindex(@objectname,@tablename)=0 --此判断不严密
begin
print 'object not in current database'
return
end
if OBJECTPROPERTY(@objectId,'IsTable') < > 1 -- 判断对象是否是table
begin
print 'The object is not table'
......

c#启动Sql Server服务

程序启动Sql Server其实很简单
代码:
System.ServiceProcess.ServiceController   myController   =
new   System.ServiceProcess.ServiceController("MSSQL$ACCP4444"); //服务名称 找了半天才找到,笨死我完了。在服务上右键属性,能看到
if (myController.CanStop)
{ }
else
{
   myController.Start();
}
//注 需要引用 System.ServiceProcess 在项目->添加引用->能找到这个引用。 ......

c#启动Sql Server服务

程序启动Sql Server其实很简单
代码:
System.ServiceProcess.ServiceController   myController   =
new   System.ServiceProcess.ServiceController("MSSQL$ACCP4444"); //服务名称 找了半天才找到,笨死我完了。在服务上右键属性,能看到
if (myController.CanStop)
{ }
else
{
   myController.Start();
}
//注 需要引用 System.ServiceProcess 在项目->添加引用->能找到这个引用。 ......

Sql Server基本函数

原文地址:http://www.programfan.com/article/2597.html
1.字符串函数
长度与分析用
datalength(Char_expr) 返回字符串包含字符数,但不包含后面的空格
substring(expression,start,length) 不多说了,取子串
right(char_expr,int_expr) 返回字符串右边int_expr个字符
字符操作类
upper(char_expr) 转为大写
lower(char_expr) 转为小写
space(int_expr) 生成int_expr个空格
replicate(char_expr,int_expr)复制字符串int_expr次
reverse(char_expr) 反转字符串
stuff(char_expr1,start,length,char_expr2) 将字符串char_expr1中的从
start开始的length个字符用char_expr2代替
ltrim(char_expr) rtrim(char_expr) 取掉空格
ascii(char) char(ascii) 两函数对应,取ascii码,根据ascii吗取字符
字符串查找
charindex(char_expr,expression) 返回char_expr的起始位置
patindex("%pattern%",expression) 返回指定模式的起始位置,否则为0
2.数学函数
abs(numeric_expr) 求绝对值
ceiling(numeric_expr) 取大于等于指定值的最小整数
exp(float_expr) 取指数
floor(numeric_expr) 小于等于指定值得最大整数
pi() 3.1415926.........
power(numeric_ex ......

SQL查询朋友关系圈应用实例

原贴:http://topic.csdn.net/u/20100412/11/a4ea520e-7dd0-44d2-98bb-9f62f0ed6160.html?21233
--------------------------------------------------------------------------
--  Author : htl258(Tony)
--  Date   : 2010-04-14 06:02:36
--  Version:Microsoft SQL Server 2008 (RTM) - 10.0.1600.22 (Intel X86)
--          Jul  9 2008 14:43:34
--          Copyright (c) 1988-2008 Microsoft Corporation
--          Developer Edition on Windows NT 5.1 <X86> (Build 2600: Service Pack 2)
--------------------------------------------------------------------------
--> 生成测试数据表:tb
 
IF NOT OBJECT_ID('[tb]') IS NULL
    DROP TABLE [tb]
GO
CREATE TABLE [tb]([callno] INT,[calledno] INT,[groupid] INT)
INSERT [tb]
SELECT 111,1000,1 UNION ALL
SELECT 111,2000,1 UNION ALL
SELECT 222,1000,2 UNION ALL
SELE ......
总记录数:40319; 总页数:6720; 每页6 条; 首页 上一页 [1794] [1795] [1796] [1797] 1798 [1799] [1800] [1801] [1802] [1803]  下一页 尾页
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号