• <legend id='ur5PC'><style id='ur5PC'><dir id='ur5PC'><q id='ur5PC'></q></dir></style></legend>

    <small id='ur5PC'></small><noframes id='ur5PC'>

    <tfoot id='ur5PC'></tfoot>
  • <i id='ur5PC'><tr id='ur5PC'><dt id='ur5PC'><q id='ur5PC'><span id='ur5PC'><b id='ur5PC'><form id='ur5PC'><ins id='ur5PC'></ins><ul id='ur5PC'></ul><sub id='ur5PC'></sub></form><legend id='ur5PC'></legend><bdo id='ur5PC'><pre id='ur5PC'><center id='ur5PC'></center></pre></bdo></b><th id='ur5PC'></th></span></q></dt></tr></i><div id='ur5PC'><tfoot id='ur5PC'></tfoot><dl id='ur5PC'><fieldset id='ur5PC'></fieldset></dl></div>
      <bdo id='ur5PC'></bdo><ul id='ur5PC'></ul>

      1. 用于保存整数列表的 SQL 变量

        SQL variable to hold list of integers(用于保存整数列表的 SQL 变量)

        <small id='FrXpV'></small><noframes id='FrXpV'>

      2. <legend id='FrXpV'><style id='FrXpV'><dir id='FrXpV'><q id='FrXpV'></q></dir></style></legend>
            • <bdo id='FrXpV'></bdo><ul id='FrXpV'></ul>

              <tfoot id='FrXpV'></tfoot>
                <tbody id='FrXpV'></tbody>
              <i id='FrXpV'><tr id='FrXpV'><dt id='FrXpV'><q id='FrXpV'><span id='FrXpV'><b id='FrXpV'><form id='FrXpV'><ins id='FrXpV'></ins><ul id='FrXpV'></ul><sub id='FrXpV'></sub></form><legend id='FrXpV'></legend><bdo id='FrXpV'><pre id='FrXpV'><center id='FrXpV'></center></pre></bdo></b><th id='FrXpV'></th></span></q></dt></tr></i><div id='FrXpV'><tfoot id='FrXpV'></tfoot><dl id='FrXpV'><fieldset id='FrXpV'></fieldset></dl></div>
                • 本文介绍了用于保存整数列表的 SQL 变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试调试其他人的 SQL 报告,并将基础报告查询放入 SQL 2012 的查询窗口中.

                  I'm trying to debug someone else's SQL reports and have placed the underlying reports query into a query windows of SQL 2012.

                  报告要求的参数之一是整数列表.这是通过多选下拉框在报告上实现的.报告的基础查询在 where 子句中使用这个整数列表,例如

                  One of the parameters the report asks for is a list of integers. This is achieved on the report through a multi-select drop down box. The report's underlying query uses this integer list in the where clause e.g.

                  select *
                  from TabA
                  where TabA.ID in (@listOfIDs)
                  

                  我不想修改我正在调试的查询,但我不知道如何在 SQL Server 上创建一个可以保存此类数据的变量来测试它.

                  I don't want to modify the query I'm debugging but I can't figure out how to create a variable on the SQL Server that can hold this type of data to test it.

                  例如

                  declare @listOfIDs int
                  set listOfIDs  = 1,2,3,4
                  

                  没有可以保存整数列表的数据类型,那么如何在我的 SQL Server 上使用与报告相同的值运行报告查询?

                  There is no datatype that can hold a list of integers, so how can I run the report query on my SQL Server with the same values as the report?

                  推荐答案

                  表变量

                  declare @listOfIDs table (id int);
                  insert @listOfIDs(id) values(1),(2),(3);    
                  
                  select *
                  from TabA
                  where TabA.ID in (select id from @listOfIDs)
                  

                  declare @listOfIDs varchar(1000);
                  SET @listOfIDs = ',1,2,3,'; --in this solution need put coma on begin and end
                  
                  select *
                  from TabA
                  where charindex(',' + CAST(TabA.ID as nvarchar(20)) + ',', @listOfIDs) > 0
                  

                  这篇关于用于保存整数列表的 SQL 变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  How do I split flat file data and load into parent-child tables in database?(如何拆分平面文件数据并加载到数据库中的父子表中?)
                  Import / Export database with SQL Server Server Management Studio(使用 SQL Server Server Management Studio 导入/导出数据库)
                  How do you import a large MS SQL .sql file?(如何导入大型 MS SQL .sql 文件?)
                  Crystal Reports vs. Microsoft SQL Server Reporting Services(Crystal Reports 与 Microsoft SQL Server Reporting Services)
                  The report definition has an invalid target namespace rsInvalidReportDefinition(报告定义具有无效的目标命名空间 rsInvalidReportDefinition)
                  Add alternating row color to SQL Server Reporting services report(向 SQL Server Reporting Services 报告添加交替行颜色)
                    <bdo id='sjvcS'></bdo><ul id='sjvcS'></ul>

                      <legend id='sjvcS'><style id='sjvcS'><dir id='sjvcS'><q id='sjvcS'></q></dir></style></legend>

                        <small id='sjvcS'></small><noframes id='sjvcS'>

                        <tfoot id='sjvcS'></tfoot>

                              <tbody id='sjvcS'></tbody>
                            <i id='sjvcS'><tr id='sjvcS'><dt id='sjvcS'><q id='sjvcS'><span id='sjvcS'><b id='sjvcS'><form id='sjvcS'><ins id='sjvcS'></ins><ul id='sjvcS'></ul><sub id='sjvcS'></sub></form><legend id='sjvcS'></legend><bdo id='sjvcS'><pre id='sjvcS'><center id='sjvcS'></center></pre></bdo></b><th id='sjvcS'></th></span></q></dt></tr></i><div id='sjvcS'><tfoot id='sjvcS'></tfoot><dl id='sjvcS'><fieldset id='sjvcS'></fieldset></dl></div>