sp_msforeachtable对变量执行操作(sp_msforeachtable performing actions on variables)
我想弄清楚如何使用sp_msforeachtable对与其他表中存储的变量/表名匹配的所有表和变量执行操作
IE
我有一个有3列的表格:表格,变量,动作
我试图使用sp_MSforeachtable来查看哪些表和变量匹配,如果匹配,请在表上执行该操作。
如何在sp_MSforeachtable语句中调用变量名称? 我知道要使用? 对于表名,但不知道我怎么说如果变量名=变量名,那么做X.
有没有另一种方式来做到这一点,而不使用这种无证的SP?
我试着更好地解释一下:
我试图从一堆表中清除个人信息...我有一张表,看起来像这样(不知道如何格式化表,所以想象每个条目是一个单独的行,所以第一行是名称,A,并设置为'')
变量
名称
电话号码
名称表
一个
一个
乙行动
设置 ''
设为'555-555-5555'
设置 ''等等
然后我有一个数据库充满了表....在表A,我想我的代码设置变量'名称'的所有行
到''(空白)
,电话号码为'555-555-5555'
然后转到表B并执行相同的操作等等I am trying to figure out how to use sp_msforeachtable to perform an action on all tables and variables that match variable/table names stored in another table
IE
I have a table that has 3 columns : table, variable, action
and I am trying to use sp_MSforeachtable to see which tables and variables match, and if match, perform that action on the table.
How do you call variable names in the sp_MSforeachtable statement? I know to use ? for the table name, but not sure how I would say if variable name=variable name then do X
Is there another way to do this without using this undocumented SP?
Ill try to explain better:
I am trying to clean personal info from a bunch of tables... I have a table that looks like this (not sure how to format a table, so imagine each entry is a seperate row, so the first row is Name, A, and set to '')
Variable
Name
Phone Number
NameTable
A
A
BAction
Set to ''
Set to '555-555-5555'
Set to ''etc.
I then have a database full of tables....on table A, I would want my code to set all rows of variable 'Name'
to '' (blank)
, and Phone Number to '555-555-5555'
etc.and then move on to table B and do the same and so on
原文:https://stackoverflow.com/questions/35043605
最满意答案
细胞背景的条件格式
右键单击“
Portfolio
字段以访问属性在“
Fill
选项卡上打开“Fill color:
的表达式编辑器输入表达式以评估“
Portfolio
字段的值并根据需要设置颜色。
排序
您可以使用两种方法对报表中的结果进行排序,无论是在数据集中还是在报表中的表/矩阵中。 测试哪种方法最适合您的情况。
数据集排序
假设列名称是数据库中的
Portfolio
,请将以下内容添加到数据集查询中:ORDER BY Portfolio DESC;
Tablix排序
右键单击报表设计中的Tablix:
在
Portfolio
字段上设置降序排序:请记住,如果您希望
Portfolio
值为B
所有行都排在报表顶部,则需要删除RepName
分组。 查看示例输出:分组
没有分组
Conditional Formatting of Cell Background
Right-click the
Portfolio
field to access propertiesOpen the expression editor for
Fill color:
on theFill
tabEnter the expression to evaluate value of the
Portfolio
field and set color as appropriate.
Sorting
You have two options for sorting results, either in the dataset or in the table/matrix on the report. Test to see which works best for your situation.
Dataset sort
Assuming the column name is
Portfolio
in the database, add the following to your dataset query:ORDER BY Portfolio DESC;
Tablix sort
Right-click the tablix in report design:
Set descending sort on the
Portfolio
field:Keep in mind that if you want all rows with
Portfolio
value ofB
to sort at the top of the report, you'll need to remove theRepName
grouping. See sample output:Grouped
Not grouped
相关问答
更多-
我们必须做类似的事情(即来自不同服务器的内部连接2数据源)。 我相信最好的方法是编写自己的自定义数据扩展。 这不是很困难,它会让你有能力做到这一点和更多。 We had to do something similar (i.e. inner join 2 data sources from different servers). I believe the best way is to write your own custom Data Extension. It's not very difficult ...
-
这是你需要做的。 请检查您的设计中是否缺少任何配置。(我觉得您的分组配置中存在一些问题,但如果没有问题中提供的行组详细信息则无法验证) 步骤1: 添加列: 第2步: 将ParentGroup添加到“(详细信息)”,并按ProductCode对其进行分组。 你会得到这个: 第3步: 这将给你行详细信息行组(在这种情况下是数量) 最终答案:使用所有“ProductCode” 使用过滤的“ProductCode” 在ProductCode组上添加过滤器: Here is what you need to do. ...
-
SSRS 2005订阅更改(SSRS 2005 Subscription changes)[2023-08-31]
我不确定您是如何访问SSRS的,但您可以使用以下Web服务方法下载和上载报告订阅 ListSubscriptions GetSubscriptionProperties GetDataDrivenSubscriptionProperties DeleteSubscription CreateDataDrivenSubscription CreateSubscription 使用这些方法,您可以使用ListSubscriptions获取报告的子描述。 Subscription.IsDataDriven属性将告 ... -
在页面中的ssrs报告中获取上一个,当前和下一个记录(Get previous,current and Next Record in ssrs report in a page)[2023-10-06]
我已经按类别创建了一个带行号的样本数据集,在您的情况下,它应该是ID。 添加Tablix并使用此表达式。 对于Next列使用。 =Lookup(Fields!Row.Value+1,Fields!Row.Value,Fields!Category.Value,"DataSetName") 它产生: 请注意,对于行号1,没有先前的类别,因此单元格为空,对于没有下一个类别的最后一个行号,存在相同的条件。 对于您的数据集,它应该是: =Lookup(Fields!Row.Value+1,Fields!Row.V ... -
SSRS'where clause'(SSRS 'where clause')[2022-06-01]
你的表达应该使用SUM而不是count =SUM(IIF(Fields!Sales_Transaction.Value=0,0,1)) Your expression should use SUM instead of count =SUM(IIF(Fields!Sales_Transaction.Value=0,0,1)) -
排序发生在每个组内,即“按预期工作”。 您正在基于无序集合中的行位置创建一些有意义且随机的记录组。 在应用任何类型的分组之前,您需要找到一种正确排序的方法(在SQL中?),或者使用较少随机的分页方法。 The sorting is happening within each group, aka, "working as intended." You're creating a somewhat arbitrary and random set of record groups based on row p ...
-
SSRS管理参数默认值2007年到2010年的不同行为(SSRS Managing parameters default value different behavior 2007 to 2010)[2023-01-20]
在与Microsoft支持部门联系之后,这是SQL Server 2008 R2中已确认的错误,并已在内部解决。 向公众发布的版本将发布在SQL Server 2008 R2 Service Pack 2中,其发布日期为TDB。 http://connect.microsoft.com/SQLServer/feedback/details/696890/ssrs-manage-parameters-in-sharepoint-2010-dynamic-parameter-values-not-loaded ... -
细胞背景的条件格式 右键单击“ Portfolio字段以访问属性 在“ Fill选项卡上打开“ Fill color:的表达式编辑器 输入表达式以评估“ Portfolio字段的值并根据需要设置颜色。 排序 您可以使用两种方法对报表中的结果进行排序,无论是在数据集中还是在报表中的表/矩阵中。 测试哪种方法最适合您的情况。 数据集排序 假设列名称是数据库中的Portfolio ,请将以下内容添加到数据集查询中: ORDER BY Portfolio DESC; Tablix排序 右键单击报表设计中的Tabl ...
-
SSRS项目,文件结构(SSRS project, files structure)[2022-08-05]
现在使用Geoff Hudik的方法: http : //www.geoffhudik.com/tech/2011/10/13/uploading-ssrs-reports-with-powershell.html 这是一个PowerShell函数,允许使用wcf接口将多个报告上载到ReportServer,因此可以自动发布。 用法很简单: UploadReports "report-server.domain.com" "c:\temp" "/TEST1/AppName" Using Geoff Hud ... -
这个问题的最佳通用答案可能是: 打开并检查RDL文件中的代码 :它只是一个XML文件,即使您不了解具体细节,您也可能能够发现导致报告无法控制的内容。 除了这个通用提示之外,还有两件事可以解决您提到的具体问题: 如果您在报表中使用特定字体 ,那些可能包含在呈现的PDF中? (我不是100%确定SSRS是否会这样做,但检查不会有什么坏处。) 检查是否有作为资源嵌入的 “延迟” 图像 :未使用但仍嵌入的图像。 查看作为资源嵌入的图像,并完全删除不再使用的图像。 The best generic answer to ...