Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is there a way to add a custom button to the SSMS tool bar? 1

Status
Not open for further replies.

DougP

MIS
Dec 13, 1999
5,985
US
In I have gobs of macros in Word, Excel and PowerPoint. I click a button I made, in the Quick Access tool bar, of any of those programs. It then pops up a form or whatever.
So I was wondering if there was a way to click a button on the SSMS tool bar and have it run a script of even a SP or something like this:
This shows the tables and dates, most recent on top. Just as an example of one I use often.

Code:
SELECT
        [name]
       ,create_date
       ,modify_date
FROM
        sys.tables
        Order by modify_date DESC

DougP
 
You can assign key combinations to certain queries. To do this:

Click Tools -> Options
Expand Keyboard
Click on Query Shortcuts



-George
Microsoft SQL Server MVP
My Blogs
SQLCop
twitter
"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
OK I made it into an SP, then picked Ctrl+3 from the menus as mentioned above. I pasted in the name sp_Utility_ListTablesByCreationDate.
Pressed Ctrl and the number 3, but nothing happens?
What am I supposed to do?

Code:
ALTER Procedure [dbo].[sp_Utility_ListTablesByCreationDate]
AS
SELECT
        [name]
       ,[create_date]
       ,[modify_date]
FROM
        sys.tables
        Order by modify_date DESC

DougP
 
I'm not 100% sure, but I think you need to restart SQL Server Management Studio.

-George
Microsoft SQL Server MVP
My Blogs
SQLCop
twitter
"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
I created a simple database called db1, with a table called table_1, with two columns f1 pk and int and identity and f2 default nchar(10)

I then ran the following to populate it:
Code:
declare @a int
set @a = 0

while @a < 10
begin
	insert into table_1 (f2)
		values ('Rubbish' + cast(@a as NCHAR(1)))
	set @a = @a + 1
end

I then created a simple sp:

Code:
ALTER PROCEDURE [dbo].[proc1] 

AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for procedure here
	SELECT * from Table_1 
END

Subsequently I executed the sp:

Code:
exec db1.dbo.proc1

which returned the expected results.


I then set up the Ctrl + 3 key with the sp name as: db1.dbo.proc1


Finally I pressed Ctrl + 3 from the local db and also from the master db and both worked as expected.

So maybe you just need to use dbname.dbowner.procname
 
DougP,

Something I notice different between softhemc and your macro (besides the dbname.dbowner.object) is that softhemc included EXEC in the macro. Try adding EXEC and see if that works.

-SQLBill

The following is part of my signature block and is only intended to be informational.
Posting advice: FAQ481-4875
 
SWEET guys SWEET
Acually I had to leave out the database name so mine is just
dbo.SP_name

Anyway it WORKS Great Whew who

DougP
 
So I guess we can't make a button on the tool bar to run this, right?

DougP
 
Not sure about the toolbar thing, but have you considered creating a Database Project with all your queries in it? Then you can always just open the Project and execute one or more of the queries you use on a regular basis.

=======================================
People think it must be fun to be a super genius, but they don't realize how hard it is to put up with all the idiots in the world. (Calvin from Calvin And Hobbs)

Robert L. Johnson III
CCNA, CCDA, MCSA, CNA, Net+, A+, CHDP
C#.NET Programmer
 
In SQL Server Manager Studio, you can create a Database Project (File | New | Project SQL Server Scripts). Normally used for grouping stored procedures and other database objects together for application work, you may be able to leverage it. In this project, you set up connections to your servers and stored all your queries and code. When you open the project....it is all there on the screen and you only need to run the queries you want/need at the time. This way, you don't have to open each query file separate through the menu. I am not sure if it will completely fill your need, but it might get you pretty close.

=======================================
People think it must be fun to be a super genius, but they don't realize how hard it is to put up with all the idiots in the world. (Calvin from Calvin And Hobbs)

Robert L. Johnson III
CCNA, CCDA, MCSA, CNA, Net+, A+, CHDP
C#.NET Programmer
 
mstrmage1768, is this available in SSMS express 2010? I don't see it listed :(

DougP
 
I don't have the express version, but it is possible it doesn't exist there.

=======================================
People think it must be fun to be a super genius, but they don't realize how hard it is to put up with all the idiots in the world. (Calvin from Calvin And Hobbs)

Robert L. Johnson III
CCNA, CCDA, MCSA, CNA, Net+, A+, CHDP
C#.NET Programmer
 
If I am not mistaken, the SQL Server Management Studio that ships with SQL Server 2012 Express has all the functionality you are looking for. So... you can download this and install just the Management Studio. You don't need to install the database engine because SSMS 2012 can connect to any version of SQL.



-George
Microsoft SQL Server MVP
My Blogs
SQLCop
twitter
"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Well its there in both versions, my mind was confused the other day. I was looking in the "Tools" menu not the file menu.
I have 2008 on XP, and 2012 on windows 8.

DougP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top