--查看当前的存放位置 select database_id,name,physical_name AS CurrentLocation,state_desc,size from sys.master_files where database_id=db_id(N'数据库名'); --修改文件的存放位置下次启动生效 --testDb为数据库名, alter database 数据库名 modify file ( name = 文件名(不包含后缀), filename = '文件存储路径'); alter database 数据库名 modify file ( name = 文件名(不包含后缀), filename = '文件存储路径'); eg. alter database testDb modify file ( name = testDb, filename = 'G:\SQL_DATA\testDb\testDb.mdf'); alter database testDb modify file ( name = testDb_log, filename = 'G:\SQL_DATA\testDb\testdb_log.ldf'); --修改默认的数据库文件存放位置(即时生效) EXEC xp_instance_regwrite @rootkey='HKEY_LOCAL_MACHINE', @key='Software\Microsoft\MSSQLServer\MSSQLServer', @value_name='DefaultData', @type=REG_SZ, @value='E:\MSSQL_MDF\data' GO --修改默认的日志文件存放位置(即时生效) EXEC master..xp_instance_regwrite @rootkey='HKEY_LOCAL_MACHINE', @key='Software\Microsoft\MSSQLServer\MSSQLServer', @value_name='DefaultLog', @type=REG_SZ, @value='E:\MSSQL_MDF\log' GO
by 刘迎光@萤火虫工作室
OpenBI交流群:49
SELECT StartTime,CONVERT(datetime,case when datepart(mi,StartTime)<30 then CONVERT(varchar(100), StartTime, 23)+ ' ' +datename(hh,StartTime)+':00:00' else CONVERT(varchar(100), StartTime, 23)+ ' ' +datename(hh,StartTime)+':30:00' end) as HourPartFROMWGS_MainCDR_201401TEMPGROUP BY StartTime,CONVERT(datetime,case when datepart(mi,StartTime)<30 then CONVERT(varchar(100), StartTime, 23)+ ' ' +datename(hh,StartTime)+':00:00' else CONVERT(varchar(100), StartTime, 23)+ ' ' +datename(hh,StartTime)+':30:00' end)
StartTime HourPart2014-01-16 01:59:25.203 2014-01-16 01:30:00.0002014-01-16 01:59:30.627 2014-01-16 01:30:00.0002014-01-16 01:59:35.297 2014-01-16 01:30:00.0002014-01-16 01:59:46.063 2014-01-16 01:30:00.0002014-01-16 02:00:15.327 2014-01-16 02:00:00.0002014-01-16 02:00:19.157 2014-01-16 02:00:00.0002014-01-16 02:27:46.327 2014-01-16 02:00:00.0002014-01-16 02:28:46.327 2014-01-16 02:00:00.0002014-01-16 02:39:31.000 2014-01-16