While Loop to Iterate through Databases

后端 未结 7 1196
暖寄归人
暖寄归人 2021-02-05 13:05

I was wondering if someone could help me with creating a while loop to iterate through several databases to obtain data from one table from two columns. this is was I have done

7条回答
  •  盖世英雄少女心
    2021-02-05 13:43

    You don't have to use a "USE DATABASE" statement. You can select from the particular database table by using a 3 part identifier as in:

    select * from MyDatabase.dbo.MyTable

提交回复
热议问题