Because of the need to periodically remove the longer-term information, which is not directly created by Azure SQL db at the moment, one way to do this is to execute Azure SQL instructions through local SQL server.
The steps are as follows:
SQL Server Management Studio 2014, after logging on local, open SQL Server Agent
New industry, enter the name:
Added step, the input name is "create list":
Type select "Operating System (CMDEXEC)", perform identity "sql Server Agent service Mega",
The command is:
sqlcmd-u"Mega"-d"Information repository name"-s"xxxxxxx.database.windows.ne"t-p"login"-i C:\script\deleteLog.sql-o c:\script\azureoutput. Tx
C:\script\deleteLog.sql This script is required to perform SQL language, such as delete table and so on;
- -U Azure SQL logging Mega user
- -D Information Repository name
- -P Azure SQL login password
- -I execute the script path
- -O Execute Results output file
Setup Output files:
Add the following schedule:
The type is "repetitive".
Born "Daily"
Repeat frequency "1" days
The Activity Viewer can view all the operating status of the industry, and if it is wrong, you can view the file specified in the previous step-O.
Deletelog.sql is as follows:
DELETE from Tkblsts where Job_no in (SELECT job_no from TKBL where (group_id<> ' EG ' and group_id<> ' PL ') and CRE Ate_date < DATEADD (Month,-4,getdate ())); Godelete from Tkblpty where Job_no in (SELECT job_no from TKBL where (group_id<> ' EG ' and group_id<> ' PL ') and C Reate_date < DATEADD (Month,-4,getdate ())); Godelete from Tkblcntr where Job_no in (SELECT job_no from TKBL where (group_id<> ' EG ' and group_id<> ' PL ') and Create_date < DATEADD (Month,-4,getdate ())); Godelete from Tkblflno where Job_no in (SELECT job_no from TKBL where (group_id<> ' EG ' and group_id<> ' PL ') and Create_date < DATEADD (Month,-4,getdate ())); Godelete from Tkblpo where Job_no in (SELECT job_no from TKBL where (group_id<> ' EG ' and group_id<> ' PL ') and CR Eate_date < DATEADD (Month,-4,getdate ())); Godelete from TKBL WHERE (group_id<> ' EG ' and group_id<> ' PL ') and Create_date < DATEADD (Month,-4,getdate () ); Godelete from Oth_log1 WHERE create_date < DATEADD (Day,-10,getdate ());
Azure SQL Business