Crosstab queries using PIVOT in SQL Server
In this tip we look at how to construct a SQL Server PIVOT query with an example and explanation.
2019-04-04
In this tip we look at how to construct a SQL Server PIVOT query with an example and explanation.
2019-04-04
If a table runs out of IDENTITY values then it, and any dependent services and applications, will be "read-only" until the problem is fixed. Steve Jones explains how to set up a custom monitor to detect and prevent such problems.
2019-04-04
Last year we ran the industry’s first ever state of SQL Server monitoring survey, the results not only gave great insight for the community but helped us shape our product development to ensure we were meeting the needs that you were asking for. So what has changed in a year? Tell us for your chance to win a $250 Amazon voucher.
2019-04-03 (first published: 2019-03-21)
2,280 reads
Learn how to force all SQL Server connections to an AWS RDS instance to use SSL encrypted connections.
2019-04-02
Temporal tables were introduced with SQL Server 2016. To take advantage of this feature, you might start fresh with a brand new table. It is possible, however, to convert an existing table with accumulated history to the new functionality. In this article, Mala Mahadevan explains how to create temporal tables for both scenarios.
2019-04-01
When you index a nullable field, are the rows with nulls stored in the index? It’s easy enough to find out by creating a table with a nullable field, and then creating an index on it.
2019-03-29
Even when creating games, your code has access to environment variables and document files. In this article, Lance Talbert shows how to access files to convince the player that maybe the game knows more than it should.
2019-03-28
In this article we walk through a step-by-step example on how to create an Azure Data Lake Linked Service in Azure Data Factory v2.
2019-03-27
Back to the basics: learn how to Create, Read, Update and Delete operations are pivotal for any database application. Plus, you’ll see how to use Stored Procedures to manipulate data on the database side instead of on the application side.
2019-03-26
This article by Adam Aspin reviews the Azure Cosmos DB SQL API from the perspective of the relational database developer. More specifically it will show you how to leverage your Structured Query Language skills to exploit the core possibilities of Cosmos DB as a NoSQL document database.
2019-03-25
219 reads
It is Friday, the queries are running, and nobody is watching the bill. That...
By Steve Jones
Annabel retired from Redgate Software this week. Across most of my career at Redgate,...
By Tim Radney
As a SQL Server DBA with years of experience tuning production environments, I’ve seen...
Comments posted to this topic are about the item What is the Cloud?
Comments posted to this topic are about the item Changing the Schema
Comments posted to this topic are about the item Index Fragmentation Explained: Page Splits,...
I set up a few users on my SQL Server 2022 instance.
CREATE LOGIN User1 WITH PASSWORD = 'Demo12#1' CREATE USER User1 FOR LOGIN User1 GO CREATE LOGIN User2 WITH PASSWORD = 'Demo12#2' CREATE USER User2 FOR LOGIN User2 GO CREATE LOGIN User3 WITH PASSWORD = 'Demo12#3' CREATE USER User3 FOR LOGIN User3 GOI then created a schema that one of them owned. Under this schema, I added a table with some data.
CREATE SCHEMA MySchema AUTHORIZATION User1
GO
CREATE TABLE Myschema.MyTable(myid INT)
GO
INSERT MySchema.MyTable
(
myid
)
VALUES
(1), (2), (3)
GO
SELECT * FROM MySchema.MyTable
GO
I granted rights and verified that User2 could access this table.
GRANT SELECT ON Myschema.MyTable TO User2 GO SETUSER 'USER2' GO SELECT * FROM MySchema.MyTable GOThis worked. Now, I move this schema to a new user.
ALTER AUTHORIZATION ON SCHEMA::Myschema TO User3; GOWhat happens with this code?
SETUSER 'USER2' GO SELECT * FROM MySchema.MyTable GOSee possible answers