1 2 /* Can be Executed in any database */3 4 /*
5 ** Syntax:
6 **
7 ** execute sp_checksource with no parameter checks source for every compiled
8 ** object in the current database. This only reserves to user with SA role.
9 **
10 ** User John can check the source of his procedure john_proc using the
11 ** following two ways:
12 **
13 ** execute sp_checksource @objname = "john_proc", @username = "John"
14 ** or
15 ** execute sp_checksource @objname = "john_proc"
16 **
17 ** User John can check the source of all the check constraints and
18 ** declaractive defaults defined on his table john_tab using the following
19 ** two ways:
20 **
21 ** execute sp_checksource @tabname = "john_tab", @username = "John"
22 ** or
23 ** execute sp_checksource @tabname = "john_tab"
24 **
25 ** User John can check the source of all the check constraints and declaractive
26 ** defaults defined on this table john_tab2 and also his view john_vu as
27 ** following:
28 **
29 ** execute sp_checksource @objname = "john_vu", @tabname = "john_tab2"
30 **
31 ** or
32 **
33 ** execute sp_checksource @objname = "john_vu", @tabname = "john_tab2" ,
34 ** @username = "John"
35 **
36 ** User John can check the source of all the compiled objects owned by him
37 ** using the following way:
38 **
39 ** execute sp_checksource @username = "John"
40 **
41 ** User John can not check the source of Mary's view mary_vu as following:
42 **
43 ** execute sp_checksource @objname = "mary_vu". @username = "Mary"
44 **
45 ** But the user with SA role can do the above.
46 **
47 ** Parameters:
48 ** objname - compiled object name
49 ** tabname - table name
50 ** username - user name
51 **
52 ** Returns:
53 ** 1 - if error.
54 ** 0 - if no error.
55 */56 createproceduresp_checksource57 @objname varchar(255)=NULL,58 @tabname varchar(255)=NULL,59 @username varchar(255)=NULL60 as61 declare@ret int
62 execute@ret=sp_aux_text@objname,@tabname,@username, 1
63 return@ret64
exec sp_procxmode 'sp_checksource', 'AnyMode'
go
Grant Execute on sp_checksource to public
go