文章分类 - SQL Server
SQL Server
摘要:方法一:convert(float,字段名) as 别名select convert(float,round(10.123232,2))结果:10.12select convert(float,round(10,2))结果:10方法二:cast(round(字段名,2) as numeric(20,...
阅读全文
摘要:execsp_renamedb'old_name','new_name'
阅读全文
摘要:SETNOCOUNTON; insertintotable1()values(''); select@@IDENTITY; SETNOCOUNTOFF;
阅读全文
摘要:select * from TableName order by newid()
阅读全文
摘要:begin transaction …… commit transaction
阅读全文
摘要:select Min(VisitTime),count(*) as Num from online group by datediff(day,VisitTime,getdate())
阅读全文
摘要:convert(varchar(10),date1,120)
阅读全文
摘要:方法一: sp_MShelpcolumns '表名' 方法二: sp_help '表名' 方法三: select * from information_schema.columns where table_name='表名' 三种方法查出来的效果不一样,可以根据情况选择使用.
阅读全文
摘要:select datepart(weekday,getdate()) 1为星期日,2为星期一,3为星期二,……
阅读全文
摘要:declare @dt datetime set @dt=getdate() select 32-Day(@dt+(32-Day(@dt)))
阅读全文
摘要:select identity(int,1,1) as id,username into #temp from table1 group by username select * from #temp
阅读全文
摘要:DBCC checkident(tablename,RESEED,1)
阅读全文
摘要:下面的示例将登录用户的密码由ok改为coffee EXEC sp_password 'ok','coffee'
阅读全文
摘要:下例将表customers重命名为custs EXEC sp_rename 'customers','custs'
阅读全文