|
|
|
|
|
|
|
Question of the Day |
Today's question (by Steve Jones - SSC Editor): | |
Who am I? | |
If I want to track which login called a stored procedure and use the value in an audit, what function can I use to replace the xxx below?
create procedure AddNewCustomer @customername varchar(200) AS BEGIN DECLARE @added VARCHAR(100) SELECT @added = xxx IF @customername IS NOT NULL INSERT dbo.Customer ( CustomerName, AddedBy ) VALUES (@customername, @added) END | |
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) |
The Maximum Value in the Identity Column I have a table with this data: TravelLogID CityID StartDate EndDate 1 1 2025-01-01 2025-01-06 2 2 2025-01-01 2025-01-06 3 3 2025-01-01 2025-01-06 4 4 2025-01-01 2025-01-06 5 5 2025-01-01 2025-01-06 I run this code: SELECT IDENT_CURRENT('TravelLog') I get the value 5 back. Now I do this: SET IDENTITY_INSERT dbo.TravelLog ON INSERT dbo.TravelLog ( TravelLogID, CityID, StartDate, EndDate ) VALUES (25, 5, '2025-09-12', '2025-09-17') SET IDENTITY_INSERT dbo.TravelLog OFF I now run this code. DBCC CHECKIDENT(TravelLog) GO INSERT dbo.TravelLog ( CityID, StartDate, EndDate ) VALUES (4, '2025-10-14', '2025-10-17') GO What is the value for TravelLogID for the row I inserted for CityID 4 and dates starting on 14 Oct 2025?
Answer: 26 Explanation: Since the max value in the column TravelLogID is greater than the identity value, when I run the DBCC CHECKIDENT command, this value (25) is inserted into the metadata storage for identity values. When the next row is inserted, it gets the value 26. Ref: DBCC CHECKIDENT - https://learn.microsoft.com/en-us/sql/t-sql/database-console-commands/dbcc-checkident-transact-sql?view=sql-server-ver17 |
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 - Administration |
Compatibility levels on database changing them and impacts. - We’re running SQL Server 2019 with database compatibility level 150, and after recent tuning (RAID-10 tempdb with even files and RCSI enabled) performance is stable; however our application vendor is asking us to drop the database’s compatibility level all the way down to 110 (SQL 2012). My concern is that this would disable many 2019 […] |
Timeout when expanding the table - Experts, I am hoping to get some help and feedback. I have a server with 5 instances on it. Out of 256 GB, I have allocated 36GB to this instance. This specific instance has been up and running for over a year now without issues. This instance also has 6 DBs. Yesterday I noticed when […] |
SQL Server 2019 - Development |
Is there a way for SP to know who called it? - Hi everyone I am writing an SP where there is logic inside the SP that depends how the SP was called. For example, Start of SP ....code.... If SSIS called SP then do A else do B .... code .... End of SP Is there a way for SP to know who asked it to […] |
SQLServerCentral.com Announcements |
SSC Website Deployment 24 Sept 2025 - We are planning on a fairly big code deployment to set the stage for some upgrades later this year. Hopefully no issues, but as with any software change, please post here or in Website Issues if you see something. |
Editorials |
Getting More Time from AI - Comments posted to this topic are about the item Getting More Time from AI |
All the Costs of Downtime - Comments posted to this topic are about the item All the Costs of Downtime |
Planning for tomorrow, today - database migrations - Comments posted to this topic are about the item Planning for tomorrow, today - database migrations |
Article Discussions by Author |
Changing the Recovery Time - Comments posted to this topic are about the item Changing the Recovery Time |
When Page Prefetching Takes a Back Seat – Exploring Trace Flag 652 in SQL Server - Comments posted to this topic are about the item When Page Prefetching Takes a Back Seat – Exploring Trace Flag 652 in SQL Server |
Single User SQL Server on Linux - Comments posted to this topic are about the item Single User SQL Server on Linux |
How Well Does the MSSQL Extension in VSCode Work? - Comments posted to this topic are about the item How Well Does the MSSQL Extension in VSCode Work? |
The Tightly Linked View - Comments posted to this topic are about the item The Tightly Linked View |
Build a Test Lab of SQL Server 2025 on Windows Server 2025 using Hyper-V Virtual Machines - Comments posted to this topic are about the item Build a Test Lab of SQL Server 2025 on Windows Server 2025 using Hyper-V Virtual Machines |
SQL Server 2022 - Administration |
Bottlenecks on SQL Server performance - We have a BI-application that connects to input tables on a SQL Server 2022 Standard edition. This is installed on a Windows Server 2022 in Azure with the size Standard E32s v5, having 32 vCPUs, 256 GB RAM, 32 data disks and 51200 max IOPS. The SQL Server is used for reading, updating and writing […] |
SQL Server 2022 - Development |
Is there some good routines for updating SQL Server database objects with GitHub - At work we've been getting better at writing what's known as GitHub Actions (workflows, YAML). I've got it deploying applications to websites, etc. It is cool. One thing users would like to have is a means of deploying updates to SQL Server database objects using GitHub Actions. I've thought about this and have come up […] |
| |
©2019 Redgate Software Ltd, Newnham House, Cambridge Business Park, Cambridge, CB4 0WZ, United Kingdom. All rights reserved. webmaster@sqlservercentral.com |