首页 \ 问答 \ sp_msforeachtable对变量执行操作(sp_msforeachtable performing actions on variables)

sp_msforeachtable对变量执行操作(sp_msforeachtable performing actions on variables)

我想弄清楚如何使用sp_msforeachtable对与其他表中存储的变量/表名匹配的所有表和变量执行操作

IE

我有一个有3列的表格:表格,变量,动作

我试图使用sp_MSforeachtable来查看哪些表和变量匹配,如果匹配,请在表上执行该操作。

  1. 如何在sp_MSforeachtable语句中调用变量名称? 我知道要使用? 对于表名,但不知道我怎么说如果变量名=变量名,那么做X.

  2. 有没有另一种方式来做到这一点,而不使用这种无证的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.

  1. 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

  2. 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
Name

Table
A
A
B

Action
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
更新时间:2022-03-29 22:03

最满意答案

细胞背景的条件格式

  1. 右键单击“ Portfolio字段以访问属性 文本框属性

  2. 在“ Fill选项卡上打开“ Fill color:的表达式编辑器 填充颜​​色表达式编辑器

  3. 输入表达式以评估“ Portfolio字段的值并根据需要设置颜色。 填充颜​​色表达文本


排序

您可以使用两种方法对报表中的结果进行排序,无论是在数据集中还是在报表中的表/矩阵中。 测试哪种方法最适合您的情况。

数据集排序

假设列名称是数据库中的Portfolio ,请将以下内容添加到数据集查询中:

ORDER BY Portfolio DESC;

Tablix排序

  1. 右键单击报表设计中的Tablix:

    Tablix属性

  2. Portfolio字段上设置降序排序: 在此处输入图像描述

请记住,如果您希望Portfolio值为B 所有行都排在报表顶部,则需要删除RepName分组。 查看示例输出:

分组

输出分组

没有分组

输出未分组


Conditional Formatting of Cell Background

  1. Right-click the Portfolio field to access properties Textbox Properties

  2. Open the expression editor for Fill color: on the Fill tab Fill color expression editor

  3. Enter the expression to evaluate value of the Portfolio field and set color as appropriate. Fill color expression text


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

  1. Right-click the tablix in report design:

    Tablix property

  2. Set descending sort on the Portfolio field: enter image description here

Keep in mind that if you want all rows with Portfolio value of B to sort at the top of the report, you'll need to remove the RepName grouping. See sample output:

Grouped

Output grouped

Not grouped

Output 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的,但您可以使用以下Web服务方法下载和上载报告订阅 ListSubscriptions GetSubscriptionProperties GetDataDrivenSubscriptionProperties DeleteSubscription CreateDataDrivenSubscription CreateSubscription 使用这些方法,您可以使用ListSubscriptions获取报告的子描述。 Subscription.IsDataDriven属性将告 ...
  • 我已经按类别创建了一个带行号的样本数据集,在您的情况下,它应该是ID。 添加Tablix并使用此表达式。 对于Next列使用。 =Lookup(Fields!Row.Value+1,Fields!Row.Value,Fields!Category.Value,"DataSetName") 它产生: 请注意,对于行号1,没有先前的类别,因此单元格为空,对于没有下一个类别的最后一个行号,存在相同的条件。 对于您的数据集,它应该是: =Lookup(Fields!Row.Value+1,Fields!Row.V ...
  • 你的表达应该使用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 ...
  • 在与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 ...
  • 现在使用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 ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。