Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/sql-server-2008/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql server 在SQL Server Express edition中创建作业_Sql Server_Sql Server 2008_Batch File_Sql Server Express - Fatal编程技术网

Sql server 在SQL Server Express edition中创建作业

Sql server 在SQL Server Express edition中创建作业,sql-server,sql-server-2008,batch-file,sql-server-express,Sql Server,Sql Server 2008,Batch File,Sql Server Express,我正在使用SQL Server 2008(快速版)。 我想创建一个作业,每天晚上1:00删除数据库中所有表(>50)中的所有数据。 我决定从脚本中恢复数据库,而不是删除 使用SQLServer代理很容易,但这是SQLServerExpress中的限制 我发现,通过创建批处理文件和SQL脚本文件,并通过Windows任务调度器运行它们,我们可以“手动”创建作业 我不知道我必须在bat文件和sql文件中写些什么。这是我第一次深入研究sql配置。有人能帮忙吗 我需要还原的脚本的名称是test.sql

我正在使用SQL Server 2008(快速版)。 我想创建一个作业,每天晚上1:00删除数据库中所有表(>50)中的所有数据。 我决定从脚本中恢复数据库,而不是删除

使用SQLServer代理很容易,但这是SQLServerExpress中的限制

我发现,通过创建批处理文件和SQL脚本文件,并通过Windows任务调度器运行它们,我们可以“手动”创建作业

我不知道我必须在bat文件和sql文件中写些什么。这是我第一次深入研究sql配置。有人能帮忙吗

我需要还原的脚本的名称是test.sql

如果任何人有不同的方法,请分享

谢谢
Prat

批处理文件需要如下所示。更改.sql文件的路径,并输入sql server信息。您可以阅读有关sqlcmd的更多信息。另请注意开关
-S和-i
上的情况,因为这很重要

sqlcmd -S <ComputerName>\<InstanceName> -i C:\test.sql
sqlcmd-S \-ic:\test.sql

第一次写入代码可能重复,请使用
sqlcmd.exe
进行检查,如果有效,请使用任务调度器进行计划。另一种方法是使用PowerShell,创建计划任务,并使用SMO与数据库交互为什么这是为MySQL标记的?@RichardSt Cyr@lad2025:感谢您提供的信息