简体   繁体   English

此 SQL 语句的正确 SQL 语法是什么

[英]What is the correct SQL syntax for this SQL statement

I am using a Content Management system (DotNetNuke) that has a MS SQL backend.我正在使用具有 MS SQL 后端的内容管理系统 (DotNetNuke)。 The logfiles for the CMS system (not SQL Server) have become enormous so I wish to delete them. CMS 系统(不是 SQL Server)的日志文件变得非常庞大,所以我想删除它们。

I'm trying to execute a Truncate statement, but apparently the LogFile table is joined to three other tables.我正在尝试执行 Truncate 语句,但显然 LogFile 表已连接到其他三个表。

A fellow in the community wrote a SQL script that takes all of this into consideration.社区中的一个人编写了一个 SQL 脚本,将所有这些都考虑在内。 The instrtuction call for:指令要求:

Install by running as script from SQL item in Host menu inside DNN or run in SQL Server Management Studio, after replacing placeholders {databaseOwner} and {objectQualifier} by its proper values from web.config file.在将占位符 {databaseOwner} 和 {objectQualifier} 替换为 web.config 文件中的正确值后,通过从 DNN 内的主机菜单中的 SQL 项目作为脚本运行或在 SQL Server Management Studio 中运行进行安装。

In the case of objectQualifier I checked web.config and it is:在 objectQualifier 的情况下,我检查了 web.config,它是:

objectQualifier=""

So my question in the following statement do I replace everything in the brackets AND delete the brackets as well with ""所以我在以下语句中的问题是我是否替换括号中的所有内容并用“”删除括号

Here is one of the many lines where I must replace this information:这是我必须替换此信息的众多行之一:

IF EXISTS (SELECT * FROM sys.sysobjects WHERE id = object_id(N'{databaseOwner}[{objectQualifier}sys_currentDNNVersion]') AND Type = N'FN')
    DROP FUNCTION {databaseOwner}[{objectQualifier}sys_currentDNNVersion]
GO

I must do the same for {databaseOwner}我必须对 {databaseOwner} 做同样的事情

I assume that you are referring to the EventLog.我假设您指的是 EventLog。 In recent versions of DNN it has been organized into 3 tables, not the single table of prior versions.在 DNN 的最新版本中,它被组织成 3 个表,而不是以前版本的单个表。

Look here: http://www.dnnsoftware.com/community-blog/cid/155180/howto-truncate-your-eventlog-in-dnn-740看这里: http : //www.dnnsoftware.com/community-blog/cid/155180/howto-truncate-your-eventlog-in-dnn-740

You can also configure the Event Log so that you don't save everything.您还可以配置事件日志,以便不保存所有内容。

If you are referring to other tables, what are they?如果您指的是其他表,它们是什么?

To add to the answer of Joe Craig.添加到乔克雷格的答案。 Before DNN 7.4 you could do this在 DNN 7.4 之前你可以这样做

TRUNCATE TABLE sitelog;
TRUNCATE TABLE schedulehistory;
TRUNCATE TABLE eventlog;

However they added 2 more columns to the EventLog with Foreign Keys so you cannot truncate it anymore.但是,他们使用外键向 EventLog 中添加了 2 列,因此您无法再截断它。

Download a script here (not mine).在此处下载脚本(不是我的)。 It will remove the constraints, truncate the tables and re-add the constraints again.它将删除约束,截断表并再次重新添加约束。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM