每次想要一个东西都要找好长时间才能找到 现就今天碰到的问题记录下来
在数据库用工作的方式来操作定时创建表的功能
上体创建工作的流程这里就不记录了 只是把要用到的一个存储过程记录一下
if object_id('create_position') is not null 如果当前存储过程存在就删除后重新创建
drop proc create_position
go
create proc create_position
as
declare @tsql nvarchar(1000),@times nvarchar(50) 定义参数
select @times = replace(replace(replace(CONVERT(varchar, getdate(), 120 ),'-',''),' ',''),':','') 获取时间并替换 这里在使用的时候记住要把后面的结果当作条件为 @tmes 查询出来
set @tsql=''
+'create table users'+@times+'('
+'userID nvarchar(50) null,'
+'userName nvarchar(50) null'
+')'
exec (@tsql)