随笔分类 -  SQL

SQL
CodeSmith 模版
摘要:using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace { public class { private _; p... 阅读全文
posted @ 2014-11-15 15:16 Struggling Rookie 阅读(84) 评论(0) 推荐(0)
SQL Server数据库远程操作
摘要:SQL Server数据库远程操作中,在使用openrowset/opendatasource前首先要启用Ad Hoc Distributed Queries服务,因为这个服务不安全所以SqlServer默认是关闭的。1、启用Ad Hoc Distributed Queries的方法SQL Serv... 阅读全文
posted @ 2014-11-14 12:26 Struggling Rookie 阅读(133) 评论(0) 推荐(0)
查询系统数据库
摘要:1.查询当前所有表select * from INFORMATION_SCHEMA.TABLES 阅读全文
posted @ 2014-11-14 12:25 Struggling Rookie 阅读(212) 评论(0) 推荐(0)
Excel
摘要:1.写入2.读取Using(FileStream fs=File.OpenRead("文件")){ //1 创建一个workBooke对象fs 创建一个Workbook对象,会自动把指定的Excel加载到workbook中 using(Workbook wk=new HSSFWorkbook(f... 阅读全文
posted @ 2014-11-12 14:52 Struggling Rookie 阅读(139) 评论(0) 推荐(0)
SQL查询多行合并成一行
摘要:问题描述:无论是在sql 2000,还是在 sql 2005 中,都没有提供字符串的聚合函数,所以,当我们在处理下列要求时,会比较麻烦:有表tb, 如下:idvalue----- ------1 aa1 bb2 aaa2 bbb2 ccc需要得到结果:id values------ --------... 阅读全文
posted @ 2014-11-07 16:16 Struggling Rookie 阅读(473) 评论(0) 推荐(0)
游标
摘要:declare @Result nvarchar(Max) declare @AuthorityZone nvarchar(Max)='' declare @Apply_Type nvarchar(50)='' declare @ProductCode nvarchar(50)='' se... 阅读全文
posted @ 2014-11-07 16:15 Struggling Rookie 阅读(119) 评论(0) 推荐(0)
sql生成20位数随机数
摘要:declare @rnd nvarchar(50)set @rnd =''while LEN(@rnd)<20 begin set @rnd =@rnd + REPLACE ( CONVERT(nvarchar, RAND ()),'0.','') while LEFT(@rnd,1)='0' se... 阅读全文
posted @ 2014-11-07 10:27 Struggling Rookie 阅读(588) 评论(0) 推荐(0)
select Into用法
摘要:1. insert into 表(列1,列2) select 列1,列2 from 表2 where....2.select * into 表2 from 表 1where...上面写法标识将表1的数据插入表2中,在运行完毕这条语句后,表2 在执行该SQL 语句钱表2 已经存在了 则报错。即:该跳语... 阅读全文
posted @ 2014-11-07 10:26 Struggling Rookie 阅读(3772) 评论(0) 推荐(0)
快照
摘要:Create dataBase UserInfo2_Shapon( Name=MySql,fileName='D:\UserInfo2.mdf')as SnapShot of MySqlselect * from UserInfoCreate Proc p_UserInfo( @ShapName n... 阅读全文
posted @ 2014-11-04 23:57 Struggling Rookie 阅读(164) 评论(0) 推荐(0)
事务
摘要:begin transacation declare @sumErrors int=0 //执行sql操作 ---------- set @sumErrors=@sumErrors+@@error ---------- set @sumErrors=@sumErrors+@@error ... 阅读全文
posted @ 2014-10-30 17:52 Struggling Rookie 阅读(148) 评论(0) 推荐(0)
使用ADO.net中的链接字符串
摘要:需要引用:System.Configuration命名空间ConfigurationManager.ConnectionStrings["sqlConnStr"].ConnectionString; 阅读全文
posted @ 2014-10-27 18:22 Struggling Rookie 阅读(114) 评论(0) 推荐(0)
sql 2000 分页
摘要:create PROCEDURE [dbo].[Proc_GetPageList]( @Tables varchar(1000), --表名 @PK varchar(100), --主键 @Fields varchar(1000) = '*', --查询的字段@SortField varchar(... 阅读全文
posted @ 2014-07-16 12:34 Struggling Rookie 阅读(310) 评论(0) 推荐(0)