Example of calling stored procedure in tsql

Source: Internet
Author: User
  1. ------------------------------------
  2. -- Author: flystone
  3. -- Version: v1.001
  4. -- Date: 2008-08-01 12:39:33
  5. ------------------------------------
  6. -- Test data: Ta
  7. If object_id ('ta ') is not null
  8. Drop table Ta
  9. Go
  10. Create Table TA (BNO int, bname nvarchar (5), Editor nvarchar (5), bpub nvarchar (7), bdate numeric (5, 1 ))
  11. Go
  12. Insert into Ta
  13. Select 1, 'database methods', 'wang ', 'gaojiao', 2006.9 Union all
  14. Select 2, 'information system', 'Liu ', 'kexue', 2006.8 Union all
  15. Select 3, 'database instance', 'wang ', 'gaojiao', 2006.9 Union all
  16. Select 4, 'database exercise ', 'zhang', 'jixie ', 2005.4
  17. Go
  18. -- Create proc
  19. Create proc proc_a
  20. @ BNO int
  21. As
  22. Select * from Ta where BNO <= @ BNO
  23. Go
  24. -- Start
  25. Select *
  26. From OpenRowSet ('sqloledb', 'server =.; uid = sa; Pwd = ', 'exec csdn_test.dbo.proc_a 2') as
  27. Select *
  28. From OpenRowSet ('sqloledb', '.'; 'sa '; '', 'exec csdn_test.dbo.proc_a 2') as
  29. Select *
  30. From OpenRowSet ('sqloledb', 'driver = {SQL Server}; server =.; uid = sa; Pwd = ', 'exec csdn_test.dbo.proc_a 2') as
  31. -- Drop proc
  32. Drop proc proc_a
  33. -- Result:
  34. /*
  35. BNo bname editor bpub bdate
  36. --------------------------------------------------------------------------------------------
  37. 1. Database principle: Wang gaojiao 2006.9
  38. 2. Information System Liu KEXUE 2006.8
  39. (The number of affected rows is 2)
  40. BNo bname editor bpub bdate
  41. --------------------------------------------------------------------------------------------
  42. 1. Database principle: Wang gaojiao 2006.9
  43. 2. Information System Liu KEXUE 2006.8
  44. (The number of affected rows is 2)
  45. BNo bname editor bpub bdate
  46. --------------------------------------------------------------------------------------------
  47. 1. Database principle: Wang gaojiao 2006.9
  48. 2. Information System Liu KEXUE 2006.8
  49. (The number of affected rows is 2)
  50. */
  51. -- End

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.