Query a JSON array in SQL
For the purpose of this post, lets not evaluate the db design option and lets focus on the operations on the json column.
Lets say we have a table of...
Converting a Vertical Table to an Horizontal Table in SQL Server
Today I've encountered a vertical table in an SQL Database and I wanted to transform it to an horizontal one. A vertical table is described as an EAV model.
Imagine...
How to Access the Previous Row and Next Row value in SELECT statement?
LAG - http://msdn.microsoft.com/en-us/library/hh231256.aspx
USE AdventureWorks2012;
GO
SELECT BusinessEntityID, YEAR(QuotaDate) AS SalesYear, SalesQuota AS CurrentQuota,
LAG(SalesQuota, 1,0) OVER (ORDER BY YEAR(QuotaDate)) AS PreviousQuota
FROM Sales.SalesPersonQuotaHistory
WHERE BusinessEntityID = 275...
GRANT permission to all stored procedures
If you need to grant a specified permission to all stored prcedures you can execute the following scriptDECLARE @User sysname SET @User = '<USER>' SELECT 'GRANT EXECUTE ON '...