Loading...
|
|
|
|
|
|
Question of the Day |
Today's question (by Steve Jones - SSC Editor): | |
No Renames | |
Which of these can't be renamed with sp_rename? | |
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 LAGing data I have some simple sales data in a SQL Server 2022 database that looks like this: TransactionDate SalesAmount 2023-01-15 1200.00 2023-02-22 1500.50 2023-03-10 900.75If I run this query, what are the sales growth amounts returned? SELECT ms.TransactionDate , ms.SalesAmount , ms.SalesAmount - LAG (ms.SalesAmount, 1) OVER (ORDER BY ms.TransactionDate) AS SalesGrowth FROM dbo.MonthlySales AS ms;Answer: NULL, 300.50, and -599.75 Explanation: The results are NULL, 300.50, and -599.75. If there is no row for LAG (or LEAD) then a NULL is returned. Ref: LAG() - https://learn.microsoft.com/en-us/sql/t-sql/functions/lag-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 - Administration |
SSRS SSL cert renewal automation? - I don't know if you are aware, but now Apple is requesting SSL certs only be valid for 45 days. A couple years ago Google was asking for 90 days. I think momentum is increasing and something is going to happen or I'll just retire. I recently spent a couple hours trying to figure it […] |
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 |
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Loading...
Loading...