SQL SERVER | Elencare le tabelle e le viste presenti nel database
SELECT Name, CASE WHEN Type = 'U' THEN 'Table' ELSE 'View' END AS 'Type', Create_Date, Modify_Date FROM SYS.OBJECTS WHERE TYPE IN (N'U', N'V') ORDER BY Name ASC
Appunti, stralci di programmazione e altro
SELECT Name, CASE WHEN Type = 'U' THEN 'Table' ELSE 'View' END AS 'Type', Create_Date, Modify_Date FROM SYS.OBJECTS WHERE TYPE IN (N'U', N'V') ORDER BY Name ASC
SELECT co.Column_Name AS 'Name' ,co.Data_Type AS 'Type' ,ISNULL(co.Character_Maximum_Length, 0) AS 'Lenght' ,CASE WHEN co.Data_Type='Bit' AND NOT co.Column_Default IS NULL THEN CASE WHEN REPLACE(REPLACE(REPLACE(ISNULL(co.Column_Default,''),'(',''),')',''),'''','') = 0 THEN 'False' ELSE 'True' END…
Lo script seguente restituisce un valore di tipo datetime relativo all’ultima domenica del mese: DECLARE @Data DATETIME = 'Data calcolo' SELECT DATEADD(DAY, DATEDIFF(DAY, '19000107', DATEADD(MONTH, DATEDIFF(MONTH, 0, @Data ), 30))…
Editare il web.config ed aggiungere alla direttiva Pages la voce maintainScrollPositionOnPostBack=”true”
Questo script visualizza l’elenco delle tabelle di un database visualizzando il relativo peso in megabyte: DECLARE @t TABLE ( Name VARCHAR(128), Rows INT, Reserved VARCHAR(20), Data VARCHAR(20), Index_Size VARCHAR(20), Unused…
EXEC sp_HelpText 'nome_stored_procedure'
Il seguente codice permette di aggiungere, in una tabella, un nuovo campo solo se questi non esiste già: IF NOT EXISTS( SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'Tabella' AND…
Da String a MemoryStream Dim _string As String = "Stringa da convertire" Dim _bytes As Byte() = System.Text.Encoding.UTF8.GetBytes(_string) Dim _memoryStream As New System.IO.MemoryStream(_bytes) Da MemoryStream a String Dim _bytes As…
For _i As Integer = 0 To _dataSet.Tables(0).Rows.Count - 1 For _j As Integer = 0 To _dataSet.Tables(0).Columns.Count - 1 Response.Write(_dataSet.Tables(0).Rows(_i)(_j).ToString & "|") Next Response.Write("<br />") Next
SELECT o.Name AS 'StoredProcedure' FROM SysObjects AS o INNER JOIN SysComments AS c ON o.ID = c.ID WHERE c. LIKE '%testo da ricercare%' AND o. = 'P'