1. open SQL Server remote connection
open SQL Server Configuration Manager
Configuration SSCM, check the SQL Server service on the left to make sure that SQL Server on the right and SQL Server Browser are running
11
on the left, select the SQLExpress protocol under the SQL Server Network Configuration node, the TCP/IP default on the right is "no", right-enable or double-click to open the Settings panel to modify it to "yes"
Select The IP Address tab and set the TCP port to "1433"
"TCP/IP" of the client protocol is also modified to "Enabled"
in the Control Panel, under System and Security under the Windows Firewall, advanced settings
inbound rules and outbound rules, select New rule, open 1433 Port
2.win7 the Telnet Service is off by default
in the Control Panel (small icon), the program and function under the turn on or off Windows features
find the "Telnet Server" and "telne Client" Two items, then select the previous tick to open the corresponding service
Enter in cmd terminal window , telnet 192.168.1.49 (IP address ) 1433 , test port is open.
3.
Custom Function call stored procedure
-- Create a student table CREATE TABLE Student ( ID int, Name varchar (30), Age int ) INSERT into student values (1, ' Zhang San ', (); INSERT into student values (2, ' John Doe ', (); INSERT into student values (3, ' Harry ', (); |
Create proc Wx$opencard (@p_appid varchar), @p_param varchar (20)) As SELECT * FROM student where id = @p_appid and age = @p_param; Go -- call a stored procedure in a function by OpenRowset Create function test () Returns table As Return SELECT * from OPENROWSET ( ' Sqloledb.1 ', ' Server=server-pc\sqlexpress;uid=root;pwd=root ', ' EXEC wx$opencard 1,22 ' ) Go |
Open OpenRowset method
sp_configure ' show advanced option ', 1;
GO
RECONFIGURE
sp_configure ' Ad Hoc distributed Queries ', 1;
GO
RECONFIGURE
Custom function call stored procedure solution in SQL Server2008