1 2 /*
3 ** Messages for "sp_lmconfig"
4 **
5 ** 17260, "Can't run %1! from within a transaction."
6 */7 createproceduresp_lmconfig8 @configname varchar(255)=NULL,/* license config option name */9 @configvalue varchar(255)= "1" /* license config value */10 as11 declare@config_id int /* config id for dbcc lmconfig */12 declare@configvaluelen int /* length of license config value */13 14 15 /*
16 ** dbcc lmconfig is not allowed in a transaction.
17 */18 if @@trancount > 0
19 begin20 /*
21 ** 17260, "Can't run %1! from within a transaction."
22 */23 raiserror 17260, "sp_lmconfig"
24 return(1)25 end26 27 set chained off28 29 settransactionisolationlevel 1
30 31 /*
32 ** Check if user has SA role, proc_role will also do auditing
33 ** if required. proc_role will also print error message if required.
34 */35 36 if(proc_role("sa_role")= 0)37 return(1)38 39 if(@confignameisNULL)40 begin41 /* Display all license configuration and license status */42 dbcc lmconfig
43 end44 else45 begin46 /* Map config name to config id for dbcc lmconfig. */47 select@config_id=case@configname48 when "edition" then 1
49 when "license type" then 2
50 when "smtp host" then 3
51 when "email recipients" then 4
52 when "email severity" then 5
53 when "smtp port" then 6
54 when "email sender" then 7
55 else 0
56 end57 58 if(@config_id= 0)59 begin60 print "Error: No matching configuration options."
61 return(1)62 end63 elseif(@configvalue= "1")64 begin65 /* (@config_id != 0) and (@configvalue is not specified) */66 /* Display the license configuration */67 dbcc lmconfig(@config_id)68 end69 else70 begin71 /* (@config_id != 0) and (@configvalue is specified) */72 /* Set the license configuration */73 if(@configvalueisnull)74 begin75 select@configvalue= "null"
76 end77 select@configvaluelen= datalength(@configvalue)78 dbcc lmconfig(@config_id,@configvalue,@configvaluelen)79 end80 end81 82 return(0)83