SqlServer
hhwydwfg
这个作者很懒,什么都没留下…
展开
-
数据库常用对象查询
--查询用户表对象信息select Tab.Name as [表名],Tab.create_date as [创建时间],Tab.modify_date as [最后修改时间], Col.Name as [列名] ,Type.name as [数据类型],Col.max_length as [字段长度], CASE WHEN pk.is_primary_key= 1 THEN 'Y' ELSE 'N' end as [是否主键], CASE WHEN Col.转载 2010-07-30 16:12:00 · 467 阅读 · 0 评论 -
Connection strings for SQL Server 2005 http://www.connectionstrings.com/
Standard SecurityData Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword;Use serverName/instanceName as Data Source to connect to a specific SQL Server instance.Are you using SQL Server 2005 Express? Don't miss the ser转载 2010-08-04 10:36:00 · 687 阅读 · 0 评论 -
sql判断临时表是否存在和创建临时表的方法
if object_id('Tempdb..#orderby') is not nulldrop table #orderbyselect * into #orderby from T_Linesselect * from #orderbySQL Server创建临时表:创建临时表 方法一: create table #临时表名(字段1 约束条件, 字段2 约束条件, .....) create t转载 2010-08-06 09:08:00 · 3555 阅读 · 0 评论 -
sql把结果集插入临时表的方法
<br />1----------select * into #orderby from ( select top 10 * from T_Lines ) table<br /> <br /> <br /> <br /> <br />2----------create table #orderby (fromarea varchar(100), toarea varchar(100))<br /><br />insert into #orderby (fromarea,toarea)<br />sele转载 2010-08-06 10:39:00 · 2980 阅读 · 0 评论 -
sql增加字段、修改字段名、删除字段、修改表名、改存储过程名!!
<br /> <br />create table tb<br />(<br /> id int<br />)<br />--增加字段、修改字段名、删除字段、修改表名<br />alter table tb add name varchar(50)<br /> <br />sp_rename 'tb.name','name','column'<br /> <br />alter table tb drop column name<br /><br />sp_rename 'tb','tbs'<br /> <转载 2010-08-06 15:25:00 · 1672 阅读 · 0 评论 -
统计数据库中表个数 和 数据库中所有表的名字
<br />SELECT count(*) FROM sysobjects WHERE XTYPE='u' <br /> <br />SELECT name FROM sysobjects WHERE XTYPE='u'转载 2010-10-14 16:38:00 · 757 阅读 · 0 评论 -
存储过程中执行参数SQL语句
--计算总记录数 if (@SqlWhere= or @sqlWhere=NULL) set @sql = select @totalRecord = count(*) from + @TableName else set @sql = select @totalRecord = count(*) from + @TableName + with转载 2011-06-09 15:05:00 · 596 阅读 · 0 评论 -
SQL语句自己汇总
备份并压缩数据库: backup database huilinfoodgroup to disk = n'd:\huilinfoodgroup_backup_2011_10_10_143947_0781250.bak' with noformat, noinit,转载 2011-10-10 14:51:59 · 294 阅读 · 0 评论