Mssql connects multiple data and integrates data into a table * method 1 $ SQL & quot; createprocOtherConnSQLasbegin & nbsp; selectSQLNCLI, Server (local ); trusted_Connect mssql connects multiple tables and integrates data into one table.
*/
// Method 1
$ SQL = "create proc OtherConnSQL
As
Begin
Select id = u_id, name = u_name, tel = u_tel from openrowset ('sqlncl', 'server = (local); Trusted_Connection = yes; ', 'select u_id, u_name, U_password, u_tel from ABC. dbo. USER_TABLE ') as t
Union all
Select id = id, name = c_name, tel = c_tel from openrowset ('sqlcl', 'server = (local); Trusted_Connection = yes; ', 'select id, c_name, c_tel from CBA. dbo. CU_TABLE ') as
End ";
// Method 2
$ Sql1 = "create proc OtherConnSQL
As
Begin
Select id = u_id, name = u_name, tel = u_tel from openrowset ('sqlncl', 'server = (local); Trusted_Connection = yes; ', 'select u_id, u_name, U_password, u_tel from ABC ...... ";
// Method 3: This is not connected
$ Sql2 = "create proc OtherConnSQL
Begin
Declare @ t_id varchar (50), @ t_name varchar (50), @ t_tel varchar (50)
Select @ id = u_id, @ name = u_name, @ tel = u_tel from openrowset ('sqlncl', 'server = (local); Trusted_Connection = yes; ', 'select u_id, u_name, U_password, u_tel from ABC. dbo. USER_TABLE ') as t
Select @ id = id, @ name = c_name, @ tel = c_tel from openrowset ('sqlncl', 'server = (local); Trusted_Connection = yes; ', 'select id, c_name, c_tel from CBA. dbo. CU_TABLE ') as
End
";