sql常用语句
use myoa
select * from
delete from department where departmentid=1
insert Department(DepartmentId,DepartmentName) values(1,'技术部')
update Department set departmentname='信息技术部' where departmentid=1
--删除表
drop table department
--删除数据库
drop database bai
--统计数据库表中记录
select count(*) as 数据库记录 from Department
相关文档:
create PROCEDURE pagelist
@tablename nvarchar(50),
@fieldname nvarchar(50)='*',
@pagesize int output,--每页显示记录条数
@currentpage int output,--第几页
@orderid nvarchar(50),--主键排序
@sort int,--排序方式,1表示升序,0表示降序排列
......
using (con)
{
con.Open();
String sqltext = "select * from emp where empno=@empno";
......
SQL Server 查询
查询的时候应该尽量按照复合索引中的顺序来做条件查询;(比如IXC中spInterActiveInstance_GetByIDToStat条件and ProcessState<>99的位置);
如果在程序中有For或者是Foreach,在存储过程中又有IF Exists,那就要看是否可以在表中加入复合索引了,IF Not Exists可以转换为IF Exists来使用索引; ......
--日期转换参数,值得收藏
select CONVERT(varchar, getdate(), 120 )2004-09-12 11:06:08
select replace(replace(replace(CONVERT(varchar, getdate(), 120 ),'-',''),' ',''),':','')20040912110608
select CONVERT(varchar(12) , getdate(), 111 )2004/09/12
select CONVERT(varchar(12) , getdate(), 112 )20040912 ......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace BuildQuery
{
/// <summary>
/// 使用提供的数据建立一个SQL查询
/// </summary>
public class BuildQuery
{
#region 类的变量
int numFieldsCount, ......