Script SQL Server
Excluir um servico do Windows
sc delete "NOME_DO_SERVIÇO" <enter>
Rodar um comando em modo de administrator
runas /savecred /user:seu_usuario_administrador "rodar_este_comando_em_modo_DOS_como_administrador"
How can I do to get the SQL Server port connection
--// Method 01EXEC xp_ReadErrorLog 0, 1, N'Server is listening on', N'any', NULL, NULL, 'DESC'GO--// Method 02SELECT local_tcp_portFROM sys.dm_exec_connectionsWHERE session_id = @@SPIDGO--// Method 03DECLARE @portNumber ...
Seek for column name all objects name
select s.name from sysobjects sinner join sys.schemas c on c.schema_id = s.uidinner join syscolumns l on l.id = s.idwhere l.name like '%produc%key%'
HTML Result - TXT / HML / CST
exec Spwritestringtofile 'select * from sysobjects' ,'c:\temp\', 'result.csv' ,@colheaders=0 ,@lastupdated=0DECLARE @FILE VARCHAR(8000) DECLARE @ROW...
HTML Result - Sample
EXEC sp_makewebtask 'C:\Temp\test.html', 'SELECT top 10 * from sysobjects'For more parameters:https://technet.microsoft.com/en-us/library/aa238843(v=sql.80).aspx
Show all columns name from object name
select l.name + ', 'from sysobjects sinner join sys.schemas c on c.schema_id = s.uidinner join syscolumns l on l.id = s.idwhere s.name like '%object_name%'
Check the version of SQL Server for a database using TSQL
SELECT @@SERVERNAME AS ServerName,CASE WHEN LEFT(CAST(serverproperty('productversion') as char), 1) = 8 THEN '2000' WHEN LEFT(CAST(serverproperty('productversion') as char), 1) = 9 THEN '2005' WHEN LEFT(CAST(serverproperty('productversion') as char), 2) = 10 THEN '2008' WHEN...
Send Email - Sample
EXEC msdb..sp_send_dbmail @profile_name = 'SQL Server - MSSQL ,@recipients = 'youremail@email.com' ,@subject = 'SQL Server - Test' ,@body_format =...
Deleting the Excel file by SSIS
Recently, I had noticed that deleting a file in SSIS using the File System Task is not straightforward specially when your file is not hardcoded in your package but it is declared as a variable. I just noticed it when I was creating a Foreach Loop Container using a File enumerator.Inside that for...