pooya1072 (1/1/2013)
can i use this to restart SQL service ...like that i Right click on Server name and Choose Restart.i want do this in T-SQL.
No, unfortunately not. You could certainly stop the service using T-SQL but would then have no way to start it again because the service would then be down. If you had a second instance running you could accomplish it but if you need to automate things I would suggest it is best to manage service-level functions, like restarts, using a tool like PowerShell.
There are no special teachers of virtue, because virtue is taught by the whole community.
--Plato