Okay, so this is my situation.
I am using Microsoft SQL Server Management Studio I currently have a query that pulls a person's license number, address, first name, last name and ID. All I need to add to complete this is to add the phone number. I just recently came into this environment and I am not entirely sure what tables contain what data. There are almost 5000 tables and I simply don't have time to go through them.
How can I see if there are any relationships between the two tables?
I tried to do
where f.phn_int_id = a.psn_int_id
person_address_line = dbo.fn_get_ent_pri_adr (b.psn_int_id, 'L'), person_address_csz = dbo.fn_get_ent_pri_adr (b.psn_int_id, 'C')
`SELECT a.car_gvr_ext_id, b.lst_nm, b.fst_nm, c.car_gvr_lic_no, e.cod_dtl_ds, concat(f.phn_ara_cd, f.phn_exc_no, f.phn_lcl_no) AS phn_no, person_address_line = dbo.fn_get_ent_pri_adr (b.psn_int_id, 'L'), person_address_csz = dbo.fn_get_ent_pri_adr (b.psn_int_id, 'C')
FROM column1 a, column2 b, column3 c, column4 d, column5 e, column6 f
WHERE a.psn_int_id = b.psn_int_id
AND a.car_gvr_int_id = c.car_gvr_int_id
AND a.car_gvr_int_id = d.car_gvr_int_id
AND d.func_int_id = e.cod_dtl_int_id
AND f.phn_int_id = a.car_gvr_int_id`
There are many ways to list columns from tables:
1- Using Information Schema Views
Select * FROM INFORMATION_SCHEMA.COLUMNS
SELECT cols.name as column_name, tbls.name as Table_name,schm.name as schema_name FROM sys.columns AS cols INNER JOIN sys.tables AS tbls ON cols.object_id = tbls.object_id INNER JOIN sys.schemas as schm ON tbls.schema_id = schm.schema_id WHERE tbls.type = 'U'
When listing columns it is easier to work with your situation