随笔分类 - Sql
摘要:create table sto (id int not null, -- 主键字段 de datetime -- 被跟踪的字段 constraint pk_sto primary key(id)) select * from sto -- 建日志表create table log_sto(logi
阅读全文
摘要:ALTER TRIGGER [dbo].[tri_test2] ON [dbo].[student] for INSERT,DELETE,UPDATEAS BEGIN if not exists (select * from deleted) --新增 insert student2(stu_id,
阅读全文
摘要:create table tb(name varchar(10),subject varchar(10),mark int) insert into tb values('A', '语文', 80) insert into tb values('A', '数学', 80) insert into t
阅读全文
摘要:1.查询数据库中的所有数据库名: SELECT (case when a.colorder=1 then d.name else null end) 表名, a.colorder 字段序号,a.name 字段名,(case when COLUMNPROPERTY( a.id,a.name,'IsId
阅读全文
摘要:--收缩LDF:USE [master]GOALTER DATABASE UltimusDB SET RECOVERY SIMPLE WITH NO_WAITGOALTER DATABASE UltimusDB SET RECOVERY SIMPLE --简单模式GOUSE UltimusDBGOD
阅读全文
摘要:create proc Get_Data( @Del_ID varchar(36))asselect * from Depts where DeptId=@Del_ID select * from Depts create procedure proc_Insert_Data @DealerID v
阅读全文
摘要:使用SqlBulk #region 方式二 static void InsertTwo() { Console.WriteLine("使用Bulk插入的实现方式"); Stopwatch sw = new Stopwatch(); DataTable dt = GetTableSchema(); u
阅读全文
摘要:declare @a intbegin set @a=(select COUNT(*) from PFT_PWK_WORKS)end; -- 必须加分号 with query as (select ROW_NUMBER() over(order by pwk_start_dt desc) AS RO
阅读全文
摘要:with tabs as ( select ROW_NUMBER() over(partition by TASKUSER order by INCIDENT) as rows,* from UltimusDB.dbo.TASKS where INCIDENT=888 ) select MAX(ro
阅读全文
摘要:string Strsql = string.Format(@"select ee.DOCUMENTNO,ee.APPLICANTNAME,ee.COMPANY,ee.REQUESTTIME,ee.REQ_TITLE, ee.INCIDENT, (datediff(d,getdate(),START
阅读全文
摘要:select SUBSTRING(b.SUMMARY,0,charindex('_',b.SUMMARY))as SUMMARY from UltimusDB.dbo.INCIDENTS b
阅读全文
摘要:if exists(SELECT *FROM [DBPersonnel].[dbo].[TB証明書] where [社員番号]='001') update [DBPersonnel].[dbo].[TB証明書] set [身分証明書]='11' where [社員番号]='001'else INS...
阅读全文
摘要:内存: 4 Gos: windows 2003数据库: ms sql server 2008目的: 查询性能测试,比较两种查询的性能SQL查询效率 step by step-- setp 1.-- 建表create table t_userinfo(userid int identity(1,1) ...
阅读全文
摘要:select * from dbo.orders group by custid with cube select custid ,row_number() over(order by empid) as number from orders select count(*) from order...
阅读全文
摘要:1 T-SQL语句用于管理SQL Server数据库引擎实例,创建和管理数据库对象,以及查询、插入、修改和删除数据。 2 3 Ø 变量 4 5 1、 局部变量(Local Variable) 6 7 局部变量是用户可以自定义的变量,它的作用范...
阅读全文

浙公网安备 33010602011771号