|
|
|
|
|
|
|
Question of the Day |
Today's question (by Steve Jones - SSC Editor): | |
The Login Types | |
In the sys.server_principals DMV, there is a type that corresponds to the type of principal stored in a row. There are SQL logins, Windows Logins, Windows Groups, Server Roles, and two other types. What are they? | |
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) |
Choosing the Column I set up a table like this: CREATE TABLE [dbo].[Employees] ( [EmpID] [int] NULL, [EmpSSN] [varchar] (5) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, [FirstName] [varchar] (200) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, [Lastname] [varchar] (200) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, [Salary] [money] NULL ) ON [PRIMARY] GO INSERT INTO dbo.Employees VALUES ( 1, '12345', 'Steve', 'Jones', 120000.0000 ), ( 2, '55544', 'Andy', 'Warren', 130000.0000 ), ( 3, '77788', 'Brian', 'Knight', 140000.0000 ), ( 4, '98765', 'Tom', 'Thumb', 100000.0000 ) GO I now run this code: DECLARE @i INT = 3, @j int; SELECT CHOOSE(@i, FirstName, LastName, Salary) FROM dbo.Employees AS e GO What happens? Answer: All 4 salaries are returned in a single column result set Explanation: The index in this case acts as the array choice and "salary" is the value selected. As this is inside a SELECT query, this column is returned, with all matching rows. Ref: CHOOSE() - https://docs.microsoft.com/en-us/sql/t-sql/functions/logical-functions-choose-transact-sql?view=sql-server-ver15 |
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 2017 - Administration |
What happens when I drop a huge table with LOBs? will the space be reused? - Thanks in advance for your help. I have a 5TB database with mutliple filegroups. The primary filegroup has one file, the .mdf and which is about 2.5TB. About 700GB of the space in the primary FG is made up of a single table which contains LOBs (Varbinar(max) column). After copying the table to a new […] |
Finding experation date - Hi, We installed the SQL Server evaluation copy, and I am trying to find out when it will expire. Is there a way I can query the system to find this information? Thank you |
Auditing logins, logoffs, better way to do it in 2017? - A bit of history - When the company I am doing work for implemented SOX practices about a decade ago, one of the things that came out was that for certain "critical" databases, all logins (and logoffs) were to be tracked, which program was used to connect, which workstation, os user and database account. At […] |
SQL Server 2017 - Development |
SELECT FROM sys tables does not work with 3 part database naming? - I am running a query from a utilities database, and I want to query a vendor database we have. I am running the query below from inside the vendor database and it works as expected. SELECT * FROM sys.dm_db_index_usage_stats xINNER JOIN sys.indexes iON x.object_id = i.object_idAND x.index_id = i.index_id Then when I change to […] |
SQL Server 2016 - Administration |
DBCC CheckDB causes TempDB grows massively ? - Hi Currently we are running DBCC CheckDB script in our server using SQL JOb every week Concern is it takes 3 hours and affect Tempdb Size grows massively after 4 times running in a row ( first time was successful and the rest is failed ) I am thinking to adjust the parameter so it […] |
Replicate a Table Receiving Inserts From a Publisher and Replicate Back - Let me quickly explain my situation and I've also included a diagram. My company is in the process of migrating to a better and sound high availability design but we need to have a temporary solution for the design we have currently. For redundancy, we have a transactional replication setup from Primary to Subscriber. We […] |
SQL Server 2016 - Development and T-SQL |
Surprised that Row_Number() has better performance than IDENTITY - I was doing some testing to see if it's more efficient to use an identity column or to use ROW_NUMBER() to simulate a unique ID for the result set. My thinking was that ROW_NUMBER() would need to do some type of evaluation of the result set in order to assign the value where IDENTITY would […] |
How to add Computed column with URL (Fixed string + another column value) - Hi, I want to add a new column to the table. Eg Table A ID 1 2 3 Desire Output Table A ID URL 1 www.google.com/sessionid = 1 (i.e 'www.google.com/sessionid'+ = ID) 2 www.google.com/sessionid = 2 (i.e 'www.google.com/sessionid'+ = ID) […] |
Administration - SQL Server 2014 |
DB Mirroring - Mirror server went down completely.Principal server is up and running. So once the Mirror server is back online, does the DB Mirroring will be re establish or the mirroring needs to be reconfigured? There is no witness and it is configured as async mode. Thanks |
SQL Server 2019 - Administration |
Sudden failure of Kerberos delegation with linked servers - This is not limited to SQL 2019, my issue is that suddenly on 1/8 all the linked servers on various SQL servers, that use Windows authentication, stopped working due to delegation failure ("Login failed for NT AUTHORITY/ANONYMOUS LOGON"). Kerberos authentication works fine on all servers, but not delegation. This applies to a variety of SQL […] |
SQL Server 2019 - Development |
group by ignore null value - Hi, I am not actually a programming but my job did need to write a bit of sql queries. Hope someone can help me here is my code select i.item_code,i.cost_standard,(select item_price.item_price where item_price.price_group = 'wholesale') as A,(select item_price.item_price where item_price.price_group = 'vnd')as B from item i left join item_price on i.item_code = item_price.item_code where i.item_code […] |
Integration Services |
Excel Connection Error: "External table is not in the expected format" - I hope your are doing well. I've been breaking my head since yesterday. I hope you can help me. I have an error on the production server. SSIS can no longer connect to an Excel file. I have an error "external table is not in the expected format". I work with Excel 2010 32 bits […] |
General |
Where is the Forum FAQ? - Where can a forum user find the FAQ or details on how to perform forum actions like deleting a post? I assume you can delete a post but I can't figure out how to, there is no DELETE link like there is an EDIT or REPLY link and its not clear within the interface how […] |
Performance Tuning |
Why is this query slow? - #pastetheplan https://www.brentozar.com/pastetheplan/?id=SJF21m0lU I'm trying to figure out what's causing this query (part of a stored procedure) to be so slow. The NOLOCK hints were an earlier attempt to stop deadlocks, I'm guessing they are likely no longer necessary. I did add an index that helped a ton, but this is still pretty slow and I'm […] |
Why is this query slow? - #pastetheplan https://www.brentozar.com/pastetheplan/?id=SJF21m0lU I'm trying to figure out what's causing this query (part of a stored procedure) to be so slow. The NOLOCK hints were an earlier attempt to stop deadlocks, I'm guessing they are likely no longer necessary. I did add an index that helped a ton, but this is still pretty slow and I'm […] |
| |
©2019 Redgate Software Ltd, Newnham House, Cambridge Business Park, Cambridge, CB4 0WZ, United Kingdom. All rights reserved. webmaster@sqlservercentral.com |