Thursday, 5 December 2013

Execute another server's SP - SQL


SELECT *
FROM    OPENROWSET( 'SQLOLEDB',
                    'Server=10.10.1.89\SQLEXPRESSR2;UID=sa;PWD=password',                  
                    'SET FMTONLY OFF;SET NOCOUNT ON; exec BASE.dbo.GetPWD @UID=''21'''
                  )

here we will execute GetPWD sp.
The GetPWD sp available in BASE database.
The BASE database available in 10.10.1.89\SQLEXPRESSR2 Machine.

--------------------------------------------------------------------------------------------


select * into temrp from STR_Item  

here str_item table have 100 rows
while execute of this line table temrp will create as per str_item table structure and fill all the selected rows.

No comments:

Post a Comment