Hot answers tagged

3

When in doubt, read the documentation first: TRUNCATE TABLE removes the data by deallocating the data pages used to store the table data and records only the page deallocations in the transaction log. So it deallocates the pages and make them available for reuse.


1

This will return the name of the view(s) and the definition (the CREATE statement) for all views that your table is in. SELECT name, definition FROM sys.objects o JOIN sys.sql_modules m on m.object_id = o.object_id WHERE definition LIKE '%<Your table name>%'


1

Why doesn't SQL Server honor the default that I placed on my table type? Actually, SQL Server does indeed hono[u]r that default as the following test (using the UDTT provided in the Question) shows: DECLARE @Test dbo.MyObject_TableType; INSERT INTO @Test (Name) VALUES ('ObjectOne'); SELECT * FROM @Test; Returns: Name Index ObjectOne ...


1

Try this ( replace tbl with your table name): WITH Unpivoted AS ( SELECT customerID ,ProductLineSlot ,ProductLine FROM ( SELECT customerID ,productLine1 ,productLine2 ,productLine3 FROM tbl ) p unpivot(ProductLine FOR ProductLineSlot IN ( productLine1 ...


1

To start with, JOIN and GROUP BY select b.BudgetDate, sum(b.BudgetAmount) - coalesce(sum(ex.ExMount),0) as BudgetLessExpenses from dbo.Budget b left join dbo.Expense ex on b.BudgetDate=ex.Date group by b.BudgetDate BTW. Shouldn't there be a UNIQUE constraint on [Budget].[BudgetDate] ?


1

On a whim, when double checking permissions, I double clicked on the actual DB mail executable. The result on the SQL Server 2014 machine was an empty command window. On SQL Server 2016 clicking the DB Mail executable presented this message: I cannot find this requirement anywhere in the SQL Server 2016 documentation, yet it is clearly a requirement. DB ...



Only top voted, non community-wiki answers of a minimum length are eligible