|
|
|
|
|
|
|
Question of the Day |
Today's question (by Steve Jones - SSC Editor): | |
The LAGging NULL | |
I have this data in a SQL Server 2022 table: player yearid team HR Alex Rodriguez 2012 NYY 18 Alex Rodriguez 2013 NYY 7 Alex Rodriguez 2014 NYY NULL Alex Rodriguez 2015 NYY 12 Alex Rodriguez 2016 NYY 9If I run this code, what are the results returned in the hrgrowth column? SELECT player , yearid , hr , hr - LAG (hr, 1, 0) IGNORE NULLS OVER (ORDER BY yearid) AS hrgrowth FROM dbo.playerstats; | |
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) |
AUTO_DROP Statistics In SQL Server 2022, what does this statement do? CREATE STATISTICS CustomerStats1 ON DimCustomer (CustomerKey, EmailAddress) WITH AUTO_DROP = ON Answer: If these statistics interfere with a schema change, they are dropped Explanation: This option drops statistics when they interfere with schema changes. Ref: CREATE STATISTICS - https://learn.microsoft.com/en-us/sql/t-sql/statements/create-statistics-transact-sql?view=sql-server-ver16 |
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 2016 - Development and T-SQL |
Nested Multi-Line Comments Q - Is the below with nested multi-line comments valid T-SQL code? I thought no because it has nested Multi-line comments but when I drop the code into SQL Server to check its I get no errors. Below is a section of the script that has the nested comments. The Closing comment marker in the last row […] |
SQL Server 2019 - Administration |
ODBC Connectivity - I am running SQL Server 2019 on my local PC - Windows 10 pro x64. I have an MSAccess application that uses a ODBC DSN to connect to the database. I am trying to connect instances of this application from other PCs running Windows 11. I cannot create a ODBC DSN from those machines to […] |
Adding Database to AG After Adding A New Master Key To Database - I have a database i need to add to AG. lets name it "TestDB", now TestDB already has a master key and i do not have the password for it, so i add a new database master key to it using the following query - USE [TestDB]; ALTER MASTER KEY ADD ENCRYPTION BY PASSWORD = […] |
Adding Database to AG After Adding A New Master Key To Database - I have a database i need to add to AG. lets name it "TestDB", now TestDB already has a master key and i do not have the password for it, so i add a new database master key to it using the following query - USE [TestDB]; ALTER MASTER KEY ADD ENCRYPTION BY PASSWORD = […] |
SQL Server 2019 - Development |
Operand data type varchar is invalid for sum operator - I have this view [dbo].[Asset Metrics - Client(Rama -Client-Test)], which makes use of multiple tables/views Below: The only change that was made in the underlying data was [Prod].[IMETA - Global Field Flows and Holdings (Period and client)_model_SAP BW]. The Value column in source contained a non numerical value "X", i removed it and replaced it […] |
SSIS Package error when running through SQL Agent job - Hi, Can someone please help me resolve below error. To run a SSIS package outside of SQL Server Data Tools you must install Standard Edition (64-bit) of Integration Services or higher. End Error DTExec: The package execution returned DTSER_FAILURE (1). I'm running my package using SQL Server agent Job. But it is throwing error as […] |
Reporting Services |
Upload report fails (SSL/TLS) but "Save As" from Report Builder works - When I use the "Upload" button from the SSRS website it fails and I get the following error in the logfile: OData exception occurred: System.Net.WebException: The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel. However, if I open the same report in Report Builder and use "Save As", it […] |
General |
Why does SSMS always pop up this window every time I get into it? - For the last few weeks every time I get into SSMS 20.2 I am presented with this window: I always select the Copy button, which supposedly would copy the top of my user settings file a new version. I would think that would take care of it, but no, the next time I get into […] |
Strategies and Ideas |
Date Type ETL Question - I'm not sure that I'm posting this in the right section, so please mods please move if that is the case. Anyway, what are the best practices for ETL jobs that move Date fields? Let's say I'm going from Oracle to SQL Server. Is it best to land the data in SQL server in some […] |
Integration Services |
Converting Non Numeric to Null - I have a numeric column called "Value" in a flat file, which contains both numeric data and non-numeric values, such as "X". I'm using the Derived Column Task in SSIS to convert the non-numeric "X" values to NULL. However, I am encountering an error during this process. Could you please assist me in resolving this […] |
Converting Non Numeric to Null - I have a numeric column called "Value" in a flat file, which contains both numeric data and non-numeric values, such as "X". I'm using the Derived Column Task in SSIS to convert the non-numeric "X" values to NULL. However, I am encountering an error during this process. Could you please assist me in resolving this […] |
Working with Oracle |
Sql server 2005 cpu spiking issue - Hi everyone, new to this sub but I was wondering what you guys would do to check on a sql server that goes from 5% cpu utilization to 99% back down to 5% every 4 seconds. I checked if it was a job and the closest one is a simple insert that runs every minute. […] |
SQL Server 2022 - Administration |
Database backup and restore questions. - Hello: I’m not one hundred percent sure on database backup and restore and have questions. Scenario · A developer accidentally deleted the production database on January 21st at 10 AM. · Questions: o How can I recover the database point of time? o Can I restore or recover the production database point of time if […] |
Possible oddity in msdb.dbo.backupset - Hi all I've written a script to keep track of how long backups are taking, which databases got a full or differential backup, and a few other bits. I'm using msdb.dbo.backupset as my base table but I think I've found something strange. According to that table, we managed to backup a 300GB database in […] |
SQL Server 2022 - Development |
how to solve a conversion failure error - Sample query reply appreciated Getting the following error: Conversion failed when converting the varchar value 'VZ34-031' to data type int. This is my query that produced the error: select count(t1.shipqty), t3.description from sales t1 left outer join return t2 on t1.company = t2.company and t1.invoicenum = t2.invoicenum left outer join reason t3 on t2.company = […] |
| |
©2019 Redgate Software Ltd, Newnham House, Cambridge Business Park, Cambridge, CB4 0WZ, United Kingdom. All rights reserved. webmaster@sqlservercentral.com |