SQL Server Find where column comes from within query window with SQL statement

hfsqlsce  于 2023-04-04  发布在  其他
关注(0)|答案(2)|浏览(123)

Let's say I have this query in SSMS:

select 
[Cars Sold],
[Cars In Lot],
[Available Cars],
[Car Models]
from
Cars c inner join CarDetails cd on 
c.CarId = cd.CarId
inner join MoreCarDetails mcd on
c.CarId = mcd.CarId
inner join ymcs on 
c.CarId = ymcs.CarId

Within the query window and without having to query all the tables or run a script that searches for column names, how can I know which table or alias the column [Cars Sold] belongs to?

If I place the cursor over the column, I'll see a popup with the column type, like this: Column Cars Sold (nvarchar(20), null) , but it doesn't show the table name.

ijxebb2r

ijxebb2r1#

SSMS does not natively provide a way to expose the table of origin for column names in the way that you are asking (no manual review, no execution of scripts), though a number of add-on solutions exist to provide this information.

8yoxcaq7

8yoxcaq72#

Turn on the Actual Execution Plan and the Output List of each element should tell you.

That's the only way I can think of but it should remind you to ALWAYS use the alias or table name when selecting columns.

相关问题