|
|
|
|
|
|
|
| Question of the Day |
Today's question (by Steve Jones - SSC Editor): | |
Changing the Schema | |
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 GO | |
Think you know the answer? Click here, and find out if you are right. | |
| Yesterday's Question of the Day (by Steve Jones - SSC Editor) |
BCP on Linux When running bcp on Linux, what is the field terminator? Answer: \t Explanation: The field terminator is \t or a tab. Ref: Use bcp on Linux - https://learn.microsoft.com/en-us/sql/tools/bcp/bcp-utility?view=sql-server-ver17#use-bcp-on-linux-and-macos |
| Database Pros Who Need Your Help |
Here's a few of the new posts today on the forums. To see more, visit the forums. |
| SQL Server 2019 - Development |
| identity increments by 10,000 when it was supposed to be 1 - hi a peer of mine who ive never known to be wrong says a new table he created with pk identity(1,1) jumped by 10000 on one insert. has anyone ever seen this anomaly? |
| Editorials |
| Follow Your Hunch - Comments posted to this topic are about the item Follow Your Hunch |
| The Slow Growing Problems - Comments posted to this topic are about the item The Slow Growing Problems |
| Liability for AI Errors - Comments posted to this topic are about the item Liability for AI Errors |
| Article Discussions by Author |
| What Happens When You Ask a Local AI to Query Your Database? - Comments posted to this topic are about the item What Happens When You Ask a Local AI to Query Your Database? |
| Detecting Characters - Comments posted to this topic are about the item Detecting Characters |
| Displaying Money - Comments posted to this topic are about the item Displaying Money |
| Calculating the Harmonic Mean in Power BI - Comments posted to this topic are about the item Calculating the Harmonic Mean in Power BI |
| Pro SQL Server Internals - Comments posted to this topic are about the item Pro SQL Server Internals |
| SQL ART: Who's Blocking Who? Visualising SQL Server Blocking With Spatial Geometry - Comments posted to this topic are about the item SQL ART: Who's Blocking Who? Visualising SQL Server Blocking With Spatial Geometry |
| Running SQLCMD II - Comments posted to this topic are about the item Running SQLCMD II |
| SQL Server 2022 - Administration |
| Running a Parameter-Sensitive Stored Procedure on a Secondary Replica - Hello , I would like to run a stored procedure on a secondary replica in an AlwaysOn Availability Group to offload read-only workload from the primary. However, this procedure currently suffers from parameter sniffing, and we sometimes need to recompile it to restore acceptable performance. I would like to know: What are the risks of […] |
| Backup Availability Group - Please I am hoping for some feedback Specifications: Windows Server 2022 SQL Server 2022 Availability Group with 4 replica I am trying to make sure I am using the best method of backing up my databases. I cannot use the Ole Hollengren jobs because of my environment Currently I have all four nodes set up […] |
| SQL Server 2022 - Development |
| Alamat BCA KCU Mojokerto ??/Wa (0817)839777 - Kontak Cs: 0817839777 Jl. HOS. Cokro Aminoto No.5, Mergelo, Jagalan, Kec. Magersari, Kota Mojokerto, Jawa Timur 61313 |
| Increment a number in a SQL Query based on a value - I have an issue where I have a Bill of Material list of items where some of the item numbers are blank. I need to give them sequential numbers from a beginning number like 9000000. then the next blank would be 9000001 and so on. I thought I could create a table and store the […] |
| |
| ©2019 Redgate Software Ltd, Newnham House, Cambridge Business Park, Cambridge, CB4 0WZ, United Kingdom. All rights reserved. webmaster@sqlservercentral.com |