SSMS 2014 Only Allow Execute F5 if Text Selected - sql-server

Update: Would like something that everyone can use, not just admin.
I tried to find if this question has already been asked before this post. In SSMS 2014, is there an option to only allow query execution if any text has been selected?
If none is selected, F5 and/or the execution button should be disabled. Thank you!

Based on my brief research, if user (like myself) who cannot run RAISERROR with severity level 20 or above, I am using SET NOEXEC ON and SET NOEXEC OFF in the very top and bottom. Then develop your script inbetween those two statements.
The downside is that there are two statements to add at 2 different locations. Also, if your script requires the use of SET NOEXEC, then this might not work.

I have this snippet that I sometimes include at the top of my queries:
raiserror('Highlight something and tell me what you''d like to do.', 20, -1) with log
Per the Microsoft Connect page titled, Add an Execute Selected Text Only to SQL Server Management Studio:
...We are considering adding this as a text-editor option for an
upcoming release. I have no way to mark it as "added to backlog", so
I'm resolving it as "Won't Fix". It's there though...
Cheers
-Sam Hughes
That was in 2011. If there is a way to do this I suspect it would be using Redgate. I'm not a redgate guru but I know that, for example, SQL Prompt will throw a warning before letting you do a DELETE or UPDATE without a WHERE clause. That's where I'd start.

Related

SQL Server: re-run same lines

The R language has this nice feature where you can re-run the same lines of code with CTRL+Shift+P. Does anyone know if that's possible with SQL Server Management Studio (SSMS)?
I find myself modify a bit of code and wanting to run it again, quickly. The highlight and execute is getting a bit repetitive. I would like a shortcut to run the same lines without the need to highlight.
Press F5 or Ctrl+E in SSMS. Both of these will run the highlighted SQL.
Hovering over the Execute button will have also displayed a tooltip to tell you this.

MS SQL Server Management Studio - How to create new schema

I want to create a new schema in SSMS with the Schema - New dialog box but I can't find how.
I know it's supposed to open when I right click on the Databases/xyz/Security/Schemas folder in the Object Explorer and select New Schema... but all I get is a query to create it.
I just started an edX course called Developing SQL Databases, there are no instructions there concerning the SSMS settings, the only instructions say that I should be able to get the Schema - New dialog box. I asked there in the discussion but nobody replies, actually there's no activity there whatsoever so probably nobody even knows I asked.
I did google it but the only relevant results I found say the same thing, right-click, New Schema... and the dialog box opens. But it doesn't.
So, what am I missing?
Expand the database in the Object Explorer, and right-click the Security folder, then select "New" (the Security folder under the database, NOT the Security folder under the server).
I realize your question is how to do this in SSMS, but the tsql code for this is only five words.
create schema MyNewSchema authorization dbo;
That seems much simpler to me.
Be sure you are searching in a right folder.
the security folder is under the database , not under the server.
as next screenshot:-
UPDATE:-
This issue is repeated here, and the soluation was the following:-
Full uninstall Manual
deletion of all MSSQL-folders in
AppData{Local|Roaming}
Reinstall
Checking for any updates
and everything is as expected, so try these steps.

SQL Server Management Studio does not use color in text editor

I currently have an issue with my SSMS since my PC has been reformatted with windows 10. It doesnt show any functions name with the correct color (should be pink), string (should be red), JOIN (should be grey), etc.
The only keyword it recognize are SELECT, INSERT, PRINT, TRANSACTION and couple more. I checked into my font & colors settings and they are set correctly. I even reinstalled twice without any difference.
EDIT:
Here is an image of how it look like, its a link because i am not allowed to embbed an image directly
EDIT2:
Here is my settings on SQL System Function
I finally found the solution. My Tools -> Options -> International Settings -> Language was set to "Same as Microsoft Windows" which is French. But the rest of my interface is in English. I guess there is a bug where the Setting are in French, but the Editor in English and cant find the color coding properly.
Hope it can help anyone with this problem!
if you would like set all the color back, 1.Tools -> 2.Option -> 3.Environment -> 4.Choose Text Editor in Show setting for, choose Use Defaults if this does not work, than the same steps above, but choose 'Keyword' in Display items in step 4, choose any color you prefer.
UPDATE
Update, GETDATE() and etc are not in keyword catalog, they are in SQL System Function,check that again
2nd UPDATE
In the SSMS, View - Registered Servers to check whether your local Server get registered in Database engine, if you do not see you local computer name shown in Local Server Groups, right click that, hit Task, then Register Local Server
3rd UPDATE
I think you need to restart SQL server database engine instead of restating SSMS only, you could restart it by right click the database engine name, hit restart, if that does not work, try to reboot your local machine

How to enable local (i.e. offline) help in SSMS 2016?

Let's have simple
SELECT 'a'
Whenever I press F1 on SELECT keyword, standalone installed SSMS 2016 launches web browser to display online help.
I want F1 to open local help for SELECT keyword.
What I have done so far:
Menu Help > Add or Remove Help Content, added books SQL Shared Language reference, Books Online, Developer Reference so help page for SELECT (Transact-SQL) is now available in help index.
Migrated help repository from C: to some more convenient place.
What else needs to be done?
Maybe checking option "I want to use local help" in help settings? But it is not present any more in SSMS 2016.
I also examined the Registry and was hunting for proper registry key(s) listening to SSMS using Process Monitor tool, but the SSMS did not seem to read anything resembling online/offline option at the moment of pressing F1.
If you think that the above steps to enable local help should be enough, consider upvoting subsequent bug report at the Microsoft.
SSMS 2016 help is broken. See these connect items, which you can vote for:
https://connect.microsoft.com/SQLServer/feedback/details/2826366/f1-help-in-ssms-2016-always-opens-online-content-ignores-local-help-library
and
https://connect.microsoft.com/SQLServer/feedback/details/2828609/ssms-2016-help-viewer-1-1-pops-up-help-docs-never-found
UPDATE:
the issue came fixed in SSMS 2016.4.1. From download page:
Fixed an issue where the F1 Help always opened online content. Users can now select whether they prefer online or offline help via the "Set Help Preference" in the Help menu.
Microsoft Connect item #2826366

IntelliSense duplicating part of table/field

I am using SQL Server 2008 R2 (10.50.4000). When I start typing the IntelliSense pops up and offers tables/columns. When I press tab to select and start typing further the IntelliSense adds characters. It is difficult to explain so hopefully the following screens will help:
I start typing:
I press TAB to select the table:
I press enter to go to next line to add my WHERE clause:
Has anyone seen anything like this before and if so can you please help.
Thanks
As suggested in the responses this was to do with RedGate SQL Prompt. I turned it off and everything works fine now. I am unsure why it only affects certain versions of SQL though.
Thanks all

Resources