TSQL中调用存储过程的例子

  1. ------------------------------------
  2. --Author:Flystone
  3. --Version:V1.001
  4. --Date:2008-08-0112:39:33
  5. ------------------------------------
  6. --TestData:ta
  7. Ifobject_id('ta')isnotnull
  8. Droptableta
  9. Go
  10. Createtableta(bnoint,bnamenvarchar(5),editornvarchar(5),bpubnvarchar(7),bdatenumeric(5,1))
  11. Go
  12. Insertintota
  13. select1,'数据库原理','wang','gaojiao',2006.9unionall
  14. select2,'信息系统','liu','kexue',2006.8unionall
  15. select3,'数据库实例','wang','gaojiao',2006.9unionall
  16. select4,'数据库习题','zhang','jixie',2005.4
  17. Go
  18. --createproc
  19. createprocproc_a
  20. @bnoint
  21. as
  22. select*fromtawherebno<=@bno
  23. go
  24. --Start
  25. select*
  26. fromOPENROWSET('SQLOLEDB','SERVER=.;UID=sa;PWD=','execcsdn_test.dbo.proc_a2')ASa
  27. select*
  28. fromOPENROWSET('SQLOLEDB','.';'sa';'','execcsdn_test.dbo.proc_a2')ASa
  29. select*
  30. fromOPENROWSET('SQLOLEDB','DRIVER={SQLServer};SERVER=.;UID=sa;PWD=','execcsdn_test.dbo.proc_a2')ASa
  31. --Dropproc
  32. dropprocproc_a
  33. --Result:
  34. /*
  35. bnobnameeditorbpubbdate
  36. --------------------------------------------------------------------------------------------
  37. 1数据库原理wanggaojiao2006.9
  38. 2信息系统liukexue2006.8
  39. (所影响的行数为2行)
  40. bnobnameeditorbpubbdate
  41. --------------------------------------------------------------------------------------------
  42. 1数据库原理wanggaojiao2006.9
  43. 2信息系统liukexue2006.8
  44. (所影响的行数为2行)
  45. bnobnameeditorbpubbdate
  46. --------------------------------------------------------------------------------------------
  47. 1数据库原理wanggaojiao2006.9
  48. 2信息系统liukexue2006.8
  49. (所影响的行数为2行)
  50. */
  51. --END

你可能感兴趣的:(Go)