use a table as a variable The 2019 Stack Overflow Developer Survey Results Are InConnecting...

Origin of "cooter" meaning "vagina"

What do the Banks children have against barley water?

What does ひと匙 mean in this manga and has it been used colloquially?

Why do we hear so much about the Trump administration deciding to impose and then remove tariffs?

How to save as into a customized destination on macOS?

What is the meaning of the verb "bear" in this context?

The difference between dialogue marks

If I score a critical hit on an 18 or higher, what are my chances of getting a critical hit if I roll 3d20?

How technical should a Scrum Master be to effectively remove impediments?

Why not take a picture of a closer black hole?

Why is the maximum length of OpenWrt’s root password 8 characters?

Delete all lines which don't have n characters before delimiter

Resizing object distorts it (Illustrator CC 2018)

How to support a colleague who finds meetings extremely tiring?

Did Section 31 appear in Star Trek: The Next Generation?

Protecting Dualbooting Windows from dangerous code (like rm -rf)

Worn-tile Scrabble

Did 3000BC Egyptians use meteoric iron weapons?

Why didn't the Event Horizon Telescope team mention Sagittarius A*?

Why was M87 targetted for the Event Horizon Telescope instead of Sagittarius A*?

Can you compress metal and what would be the consequences?

Can a flute soloist sit?

Multiply Two Integer Polynomials

What are the motivations for publishing new editions of an existing textbook, beyond new discoveries in a field?



use a table as a variable



The 2019 Stack Overflow Developer Survey Results Are InConnecting Linked ServerHow do I check for a null or empty table-valued parameter?Oracle GoldenGate add trandata errorsBenefit or use-case for empty variable / parameter / temporary table / temporary procedure names?Performance issues with partial join queryDeclare Variable to use as placeholder text for tablenames, not using declare table typeCursor That Executes a Proc that Creates An Audit TriggerDynamic SQL isn't updating tableFacing Error in “Execute Sql task” component (The type of the value (DBNull) being assigned to variable)Receiving error while creating stored procedure to insert Excel files into a table





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







0















I was wondering if there was a way to set a table name in SQL to be a variable.



I have a list of queries that hit the same table and didn't want to have to update them all so was hoping to declare the table name as a value.



Below is an example: what I wanted to do is declare the table name once and use the @tablename in the queries shown below.



/*at the field level */
SELECT
(
SELECT COUNT(DISTINCT PROVIDER_TIN) AS PROVIDER_TIN
from [Coloma].[dbo].Aetna_Medicare_2019 a
WHERE PROVIDER_TIN = '' OR PROVIDER_TIN IS NULL
) AS NULL_TINS,



(
SELECT COUNT(DISTINCT PROVIDER_ID) AS PROVIDER_ID
from [Coloma].[dbo].Aetna_Medicare_2019 a
WHERE PROVIDER_ID = '' OR PROVIDER_ID IS NULL
) AS NULL_IDS









share







New contributor




Newelle Horn is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.



























    0















    I was wondering if there was a way to set a table name in SQL to be a variable.



    I have a list of queries that hit the same table and didn't want to have to update them all so was hoping to declare the table name as a value.



    Below is an example: what I wanted to do is declare the table name once and use the @tablename in the queries shown below.



    /*at the field level */
    SELECT
    (
    SELECT COUNT(DISTINCT PROVIDER_TIN) AS PROVIDER_TIN
    from [Coloma].[dbo].Aetna_Medicare_2019 a
    WHERE PROVIDER_TIN = '' OR PROVIDER_TIN IS NULL
    ) AS NULL_TINS,



    (
    SELECT COUNT(DISTINCT PROVIDER_ID) AS PROVIDER_ID
    from [Coloma].[dbo].Aetna_Medicare_2019 a
    WHERE PROVIDER_ID = '' OR PROVIDER_ID IS NULL
    ) AS NULL_IDS









    share







    New contributor




    Newelle Horn is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.























      0












      0








      0








      I was wondering if there was a way to set a table name in SQL to be a variable.



      I have a list of queries that hit the same table and didn't want to have to update them all so was hoping to declare the table name as a value.



      Below is an example: what I wanted to do is declare the table name once and use the @tablename in the queries shown below.



      /*at the field level */
      SELECT
      (
      SELECT COUNT(DISTINCT PROVIDER_TIN) AS PROVIDER_TIN
      from [Coloma].[dbo].Aetna_Medicare_2019 a
      WHERE PROVIDER_TIN = '' OR PROVIDER_TIN IS NULL
      ) AS NULL_TINS,



      (
      SELECT COUNT(DISTINCT PROVIDER_ID) AS PROVIDER_ID
      from [Coloma].[dbo].Aetna_Medicare_2019 a
      WHERE PROVIDER_ID = '' OR PROVIDER_ID IS NULL
      ) AS NULL_IDS









      share







      New contributor




      Newelle Horn is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.












      I was wondering if there was a way to set a table name in SQL to be a variable.



      I have a list of queries that hit the same table and didn't want to have to update them all so was hoping to declare the table name as a value.



      Below is an example: what I wanted to do is declare the table name once and use the @tablename in the queries shown below.



      /*at the field level */
      SELECT
      (
      SELECT COUNT(DISTINCT PROVIDER_TIN) AS PROVIDER_TIN
      from [Coloma].[dbo].Aetna_Medicare_2019 a
      WHERE PROVIDER_TIN = '' OR PROVIDER_TIN IS NULL
      ) AS NULL_TINS,



      (
      SELECT COUNT(DISTINCT PROVIDER_ID) AS PROVIDER_ID
      from [Coloma].[dbo].Aetna_Medicare_2019 a
      WHERE PROVIDER_ID = '' OR PROVIDER_ID IS NULL
      ) AS NULL_IDS







      sql-server table-variable





      share







      New contributor




      Newelle Horn is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.










      share







      New contributor




      Newelle Horn is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.








      share



      share






      New contributor




      Newelle Horn is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked 5 mins ago









      Newelle HornNewelle Horn

      1




      1




      New contributor




      Newelle Horn is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      Newelle Horn is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      Newelle Horn is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






















          0






          active

          oldest

          votes












          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "182"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });






          Newelle Horn is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f234512%2fuse-a-table-as-a-variable%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          Newelle Horn is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          Newelle Horn is a new contributor. Be nice, and check out our Code of Conduct.













          Newelle Horn is a new contributor. Be nice, and check out our Code of Conduct.












          Newelle Horn is a new contributor. Be nice, and check out our Code of Conduct.
















          Thanks for contributing an answer to Database Administrators Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f234512%2fuse-a-table-as-a-variable%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Anexo:Material bélico de la Fuerza Aérea de Chile Índice Aeronaves Defensa...

          Always On Availability groups resolving state after failover - Remote harden of transaction...

          update json value to null Announcing the arrival of Valued Associate #679: Cesar Manara ...