Showing posts with label SQL Management Studio. Show all posts
Showing posts with label SQL Management Studio. Show all posts

02 January 2023

MS SQL - Generate insert script for selected records

If possible use Visual Studio. The Microsoft SQL Server Data Tools (SSDT) bring a built in functionality for this since the March 2014 release:
  1. Open Visual Studio
  2. Open "View" → "SQL Server Object Explorer"
  3. Add a connection to your Server
  4. Expand the relevant database
  5. Expand the "Tables" folder
  6. Right click on relevant table
  7. Select "View Data" from context menu
  8. In the new window, viewing the data use the "Sort and filter dataset" functionality in the tool bar to apply your filter. Note that this functionality is limited and you can't write explicit SQL queries.
  9. After you have applied your filter and see only the data you want, click on "Script" or "Script to file" in the tool bar
  10. Voilà - Here you have your insert script for your filtered data

Notes:
  1. Be careful, the "View Data" window is just like SSMS "Edit Top 200 Rows": you can edit data right away!
  2. Remember to add SET DATEFORMAT YMD before the INSERT command.

Via https://stackoverflow.com/a/51186767/14507440

01 March 2021

Sql Server Management Studio - SSMS 18.8 crashes when re-docking tabs

How to fix: Close all SSMS windows, and find your SQL Mgt Studio EXE file, mine was in:

C:\Program Files (x86)\Microsoft SQL Server Management Studio 18\Common7\IDE

If you cant find it, right click your shortcut you use to open SSMS and go Properties > Open File Location

Once you have found this, you will also find a file called Ssms.exe.config, open up a Notepad in Administrator Mode, and edit this file

You will then need to find an xml tag called <AppContextSwitchOverrides>, and APPEND (not replace) the following exactly:
;Switch.System.Windows.Interop.MouseInput.OptOutOfMoveToChromedWindowFix=true; Switch.System.Windows.Interop.MouseInput.DoNotOptOutOfMoveToChromedWindowFix=true

Via: https://docs.microsoft.com/answers/answers/274201/view.html

10 October 2019

Poor Man's T-SQL Formatter

Hi guys again, I fixed the files to work with SMSS 19 and 20, also changed visualstudio shell to 14 so you don't need manually changes smss config file, Enjoy

https://geogensoft.com/PoorMansTSqlFormatterEditedbyGeoGenSoft.Setup.msi

Via: https://github.com/TaoK/PoorMansTSqlFormatter/issues/283#issuecomment-2393744502



Plugin for SQL Management Studio, Visual Studio, Visual Studio Code, ...

http://architectshack.com/PoorMansTSqlFormatter.ashx



If, after an SSMS update, you have this exception:
Could not load 'The 'FormatterPackage' package did not load correctly.' - cannot find the file Microsoft.VisualStudio.Shell.12.0

This is the solution:



The issue seems to be with a binding redirect missing from SSMS. If you edit ssms.exe.config (by default at C:\Program Files (x86)\Microsoft SQL Server Management Studio 18\Common7\IDE) and add the following line inside the assemblyBinding element the package will load:

    
    


There's one for shell 9.0, 10.0, and 14.0 just not one for 12.0. I took the above from the visual studio exe.config. This will get cleared and have to be re-done any time you update SSMS.

2023-11-15 update - If copy/pasting the above xml doesn't work:
copy the same block directly from the ssms.exe.config file, and change it to .Shell.12.0






If modifyng the .config file doesn't work, try replacing Poor Man's DLL with those recompiled ones.



SQL Management Studio 2019 Setup


  1. Install the Extension in a previous version of SSMS (tested on v18 -- install it, if needed)
  2. Copy all files from
    C:\Program Files (x86)\Microsoft SQL Server Management Studio 18\Extensions
    
    to
    C:\Program Files (x86)\Microsoft SQL Server Management Studio 19\Extensions 
  3. Add this in ssms.exe.config:
    
        
        
    
    
  4. Uninstall Mangement Studio 18 (if installed only for this fix).

User gggirj on github made a working version for SMSS v19: https://simul-europe.com/PoorMansTSqlFormatterSSMSPackage.Setup.msi


Via GitHub and SSMS 19 and working version for SMSS v19

08 November 2017

Il provider 'Microsoft.ACE.OLEDB.12.0' non è registrato nel computer locale. (System.Data)

In SQL Management Studio, facendo una "Importazione/Esportazione guidata":

Impossibile completare l'operazione.

Il provider 'Microsoft.ACE.OLEDB.12.0' non è registrato nel computer locale. (System.Data)

Installare questi driver (32/64 bit in funzione della versione di SQL Management Studio!)

Questa sembra la versione precedente (non testata).



Nuovi URL per donwload:

32-bit: https://web.archive.org/web/20240214170634if_/https://download.microsoft.com/download/2/4/3/24375141-E08D-4803-AB0E-10F2E3A07AAA/AccessDatabaseEngine.exe

64-bit: https://web.archive.org/web/20240214170634if_/https://download.microsoft.com/download/2/4/3/24375141-E08D-4803-AB0E-10F2E3A07AAA/AccessDatabaseEngine_X64.exe

17 November 2015

Re-assign F5 key to refresh action in SQL Server 2014 Management Studio

- Open Management Studio
- Go to Tools >> Options
- Expand Environment >> Keyboard >> Keyboard
- In the "Show commands containing:", type "View.Refresh" and here you can observe that "Shortcuts for selected command:" will be grayed out
- Now choose "Global" in the "Use new shortcut in:" and press F5 button in "Press shortcut keys:"
- Click Assign
- Click Ok

Via.



- per abilitare li CTRL-R per visualizzare/nascondere i risultati di una query, bisogna mappare l'azione: Window.ShowResultPane
- per il "mostra risultati query come griglia" (CTRl-D), cerca Query.ResultstoGrid

19 July 2011

Configurazione tastiera SQL Management Studio e ut_VisDipendenze_sq

Ctrl+3SELECT TOP 9 * FROM
Ctrl+4EXEC sp_help
Ctrl+5SELECT * FROM
Ctrl+6EXEC sp_helptext
Ctrl+7EXEC ut_VisDipendenze_sq
Ctrl+8SELECT TOP 20 * FROM sys.objects X ORDER BY X.modify_date DESC
Ctrl+0SELECT FORMAT(COUNT(*), 'N0') AS [Conta Record] FROM


CREATE PROCEDURE ut_VisDipendenze_sq
(
 @objectName AS nvarchar(1000)
)
AS
BEGIN
 --##2019-09-17 - Boso -           OBJECT_DEFINITION
 SET NOCOUNT ON
 
 IF CHARINDEX('.', @objectName) = 0
  SET @objectName = 'dbo.' + @objectName


 DECLARE @objectId int = OBJECT_ID(@objectName)


 SELECT OBJECT_NAME(referencing_id) AS referencing_entity_name, 
  o.type_desc AS referencing_desciption, 
  COALESCE(COL_NAME(referencing_id, referencing_minor_id), '(n/a)') AS referencing_minor_id, 
  referencing_class_desc,
  referenced_server_name, referenced_database_name, referenced_schema_name,
  referenced_entity_name
  , OBJECT_DEFINITION(OBJECT_ID(referenced_entity_name)) AS referenced_Definition
  , COALESCE(COL_NAME(referenced_id, referenced_minor_id), '(n/a)') AS referenced_column_name,
  is_caller_dependent, is_ambiguous
 FROM sys.sql_expression_dependencies AS sed
 INNER JOIN sys.objects AS o ON sed.referencing_id = o.object_id
 WHERE referencing_id = @objectId
 ORDER BY referencing_entity_name, referencing_desciption



 SELECT OBJECT_SCHEMA_NAME ( referencing_id ) AS referencing_schema_name,
  OBJECT_NAME(referencing_id) AS referencing_entity_name, 
  o.type_desc AS referencing_desciption
  , OBJECT_DEFINITION(o.object_id) AS referencing_Definition
  , COALESCE(COL_NAME(referencing_id, referencing_minor_id), '(n/a)') AS referencing_minor_id, 
  referencing_class_desc, referenced_class_desc,
  referenced_server_name, referenced_database_name, referenced_schema_name,
  referenced_entity_name, 
  COALESCE(COL_NAME(referenced_id, referenced_minor_id), '(n/a)') AS referenced_column_name,
  is_caller_dependent, is_ambiguous
 FROM sys.sql_expression_dependencies AS sed
   INNER JOIN sys.objects AS o 
    ON sed.referencing_id = o.object_id
 WHERE referenced_id = @objectId
 ORDER BY referencing_entity_name, referencing_desciption



 -- HACK: Returning cross-database dependencies
 -- https://msdn.microsoft.com/en-us/library/bb677315.aspx?f=255&MSPPError=-2147217396

END
GO