Datetime显示方式SQLServer
今天在写视图时,遇到要把Datetime类型转Varchar类型。以前在ORALCE就容易,直接ToChar(getdate(),'yyyy-mm-dd')。在SQL Server 2005
select CONVERT(varchar, getdate(), 120 )
2004-09-12 11:06:08
select CONVERT(varchar(12) , getdate(), 111 )
2004/09/12
select CONVERT(varchar(12) , getdate(), 112 )
20040912
select CONVERT(varchar(12) , getdate(), 102 )
2004.09.12
select CONVERT(varchar(12) , getdate(), 101 )
09/12/2004
select CONVERT(varchar(12) , getdate(), 103 )
12/09/2004
select CONVERT(varchar(12) , getdate(), 104 )
12.09.2004
select CONVERT(varchar(12) , getdate(), 105 )
12-09-2004
select CONVERT(varchar(12) , getdate(), 106 )
12 09 2004
select CONVERT(varchar(12) , getdate(), 107 )
09 12, 2004
select CONVERT(varchar(12) , getdate(), 108 )
11:06:08
select CONVERT(varchar(12) , getdate(), 109 )
09 12 2004 1
select CONVERT(varchar(12) , getdate(), 110 )
09-12-2004
select CONVERT(varchar(12) , getdate(), 113 )
12 09 2004 1
select CONVERT(varchar(12) , getdate(), 114 )
11:06:08.177
相关文档:
今天一不冷静就把sqlserver数据库初始化了,在网上找了半天发现了几篇帖子,受益非浅,记录下
DB2中可以使得数据库回复到指定的时间点,SQL Server数据库的Recovery Model为full 或者Bulk copy的时候,是可以从日志来恢复数据库的。实际上日志中记录的一条一条的transact sql语句,恢复数据库的时候会redo这些sql语句。&nb ......
查询northwind数据库中orders中的10到20条记录
select top 10 * from orders
where orderid > ( select max(orderid) from (select top 10 orderid from orders order by orderid) as t&nbs ......
索引的创建及使用(sqlserver 2005)
为指定表或视图创建关系索引,或为指定表创建 XML 索引。可在向表中填入数据前创建索引。可通过指定限定的数据库名称,为另一个数据库中的表或视图创建索引。
Transact-SQL 语法约定
语法
Create Relational Index CREATE [ UNIQUE ] [ CLUSTERED | NONCLUSTERED ] IN ......
using System;
using System.Collections;
using System.Collections.Specialized;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Collections.Generic;
public class CommandInfo
{
public string CommandText;
public SqlPa ......
托了几天的难题,终于解决了。特分享一下
以下是一个存储过程
CREATE PROCEDURE deleteAccountAll
@id int
AS
SET XACT_abort ON
BEGIN DISTRIBUTED TRAN
delete from AccountCapital where accountid = @id
delete from logininfo where username = @id
delete from CapitalRecord where accountid ......