https://learn.microsoft.com/en-us/troubleshoot/sql/database-engine/connect/cannot-generate-sspi-context-error
https://dba.stackexchange.com/questions/93389/error-cannot-generate-sspi-context#93465
https://github.com/microsoft/CSS_SQL_Networking_Tools
25 September 2023
03 May 2023
SQL - Shrink all user databases
USE MASTER
GO
CREATE OR ALTER PROCEDURE Boso_ShrinkAllUserDB_sp
(
@DBName AS sysname = NULL
)
AS
BEGIN
--##2023-15-24 - Boso - @DBName
SET NOCOUNT ON
DECLARE @SQ NVARCHAR(MAX)
DECLARE #CUR CURSOR FOR
SELECT CONCAT('; PRINT ''** ', NAME ,' '' ; DBCC SHRINKDATABASE(', QUOTENAME(NAME) ,')') AS COMANDO
FROM SYS.DATABASES
WHERE STATE = 0 --> ONLINE DB ONLY
AND DATABASE_ID > 4 --> SKIP SYSTEM DBS
AND (@DBName IS NULL OR name = @DBName)
OPEN #CUR
FETCH NEXT FROM #CUR INTO @SQ
WHILE @@FETCH_STATUS = 0
BEGIN
EXEC SP_EXECUTESQL @SQ
FETCH NEXT FROM #CUR INTO @SQ
END
CLOSE #CUR
DEALLOCATE #CUR
END
GO
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:
Notes:
Via https://stackoverflow.com/a/51186767/14507440
- Open Visual Studio
- Open "View" → "SQL Server Object Explorer"
- Add a connection to your Server
- Expand the relevant database
- Expand the "Tables" folder
- Right click on relevant table
- Select "View Data" from context menu
- 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.
- After you have applied your filter and see only the data you want, click on "Script" or "Script to file" in the tool bar
- Voilà - Here you have your insert script for your filtered data
Notes:
- Be careful, the "View Data" window is just like SSMS "Edit Top 200 Rows": you can edit data right away!
- Remember to add SET DATEFORMAT YMD before the INSERT command.
Via https://stackoverflow.com/a/51186767/14507440
Subscribe to:
Posts (Atom)