Problems displaying this newsletter? View online.
SQL Server Central
Featured Contents
Question of the Day
 
The Voice of the DBA
 

Computer Algebra

I was a bit of a math nerd in high school and college. Some of you might have been as well, but I took advanced math all through high school, culminating with AP Calculus as a senior with 11 other kids (of about 320). In college, I started with Calculus III freshman year and went on to take 7 more semesters of various high level maths. One of those classes included analyzing data with linear regression, which we did with hand calculators and formulae.

At SQL Saturday Pittsburgh 2024, I watched a talk from Jeff Moden talk on linear regression. It was a trip down memory lane, with Jeff explaining how the process worked, the flaws, and how it could be used to do some predictions on data gathered in SQL Server. It was a great session on the topic, but I liked that Jeff showed how you can use SQL Server to do various math calculations that might be useful to work with data. I see some applications sometimes programming various formulas, but I don't often see people doing this in database queries.

This reminded me of some early programs I'd written in BASIC on an Apple II computer. We had to do labs and hand calculate out various results based on measurements. However, small mistakes in our notes sometimes created large errors in our lab reports, which would affect our grades. Sometimes we'd make a mistake in the chemistry process and sometimes we'd just write the wrong number down (or forget to do so). However, we couldn't repeat the grade, so filling out reports at home was maddening.

I wrote programs that create a form and let me enter all my data. This would calculate the results, and I could "massage" the data to get a low error count. Maybe not the most ethical method, but for high school labs where we were time and resource limited, and where our grades depended on a high level of accuracy, it seemed acceptable to me. I also learned the formulas better since I had to program and them and debug my work.

Creating a simple system to do calculations can be very handy for many of us in our lives. While there is software available for many purposes, like examining mortgages or calculating a budget, doing some of that work yourself let's you customize things, as well as ensure you understand how the program works. However, instead of C#, Python, or something else, I might use SQL these days as I use if often, and I can store data across time, something that might help me better analyze my own data.

If you've never tried math formula in SQL Server, give it a try. You might have some new appreciation for the equations you solved in school, while building a little more familiarity and skill with the language you use in your daily work.

Steve Jones - SSC Editor

Join the debate, and respond to today's editorial on the forums

 
 
  Featured Contents
SQLServerCentral Article

A First Look at SSMS 21

Steve Jones - SSC Editor from SQLServerCentral

This isn't really a first look, per se. I've seen Erin Stellato present on this a few times in MVP sessions and at the PASS Data Community Summit. However, this is a look on my machine, where I'm in control. The new version preview was announced recently, and this looks at the new process to […]

Technical Article

The SQLskills Black Friday Super Sale!

Press Release from SQLServerCentral

Starting at 4pm PST on Thursday, November 28th, SQLskills will be offering our lowest prices ever for our signature Blackbelt bundle with more than 158 hours of top-quality training.

Blog Post

From the SQL Server Central Blogs - Monday Monitor Tips: Tracking The Cost of Instances

Steve Jones - SSC Editor from The Voice of the DBA

One of the things that I’ve been asked in every operations situation is what licenses do we need for our servers. This is a rare request, often once a...

Blog Post

From the SQL Server Central Blogs - Benefits of Migrating from Azure Synapse Analytics to Microsoft Fabric

James Serra from James Serra's Blog

Many customers ask me about the advantages of moving from Azure Synapse Analytics to Microsoft Fabric. Here’s a breakdown of the standout features that make Fabric an appealing choice:...

Pro T-SQL 2022: Toward Speed, Scalability, and Standardization for SQL Server Developers

Site Owners from SQLServerCentral

Learn how to write and design simple and efficient T-SQL code. This is a hands-on book that teaches you how to write better T-SQL with examples and straightforward explanations.

 

  Question of the Day

Today's question (by Steve Jones - SSC Editor):

 

Renaming a Database

If I want to rename the OldSales database to ArchiveSales, how can I do this? (choose 2)  

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)

Running Steve's Code

Can you run this code in any of your SQL Server 2019 databases without error?

CREATE OR ALTER PROCEDURE [dbo].[StevesAmazingProc] AS SELECT Consumer_ID , Trend_Category , Bit_Trace FROM NewWorldDB.dbo.MarketTrend; GO

Answer: Yes.

Explanation: You can run this. Due to deferred name resolution the database or table don't need to exist at compile time. Ref: Deferred Name Resolution - https://learn.microsoft.com/en-us/sql/t-sql/statements/create-trigger-transact-sql?view=sql-server-ver16#deferred-name-resolution

Discuss this question and answer on the forums

 

 

 

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
Microsoft Recommendations for Update Stats? - I have an application team that is insisting on daily (and for some, weekly) jobs for UPDATE STATISTICS WITH FULLSCAN on all their databases. These jobs were created years ago by a previous DBA team. The jobs are running very long, into business hours often, one database's job is running 1.5 days, and butting heads […]
SQL Server 2016 - Administration
Possible SQL 2014 to 2016 Issue - Some Application Functions Slow/Failing - First time here...hoping I can find some direction and answers so I can devise a proper solution. Novice Basic SQL experience over the years while being the "jack of all trades' IT support, not a DB admin by any means. Issue: After vendor Application upgrade and SQL upgrade from 2014 to 2016 we cannot process […]
SQL Server 2019 - Administration
Agent job security account - Hi All, I have few sql server agent scheduled jobs which are supposed to run as NT Service\mssqlserveragent account however at times it runs using different account. Being novice in this world , I am not able to figure out where to make the change in agent job security to ensure that it only and […]
Export database and tables no table data - Trying to move a database from one sql server instance to another on separate servers . I need to only move it like a skeleton no data and looking for steps to export the database and tables. Is this possible?
SQL Server 2019 - Development
how can i tell if our db2 driver is ms or ibm or other? - i see this in the definition of a linked server on our wh sql server that i know is db2 based... @provider=N'DB2OLEDB', @provstr=N'Provider=DB2OLEDB;DBMS Platform=DB2/AS400; But unlike the info you can easily see by running the odbc data source administrator for installed odbc driver info, i dont see an oledb admin portal nor do i see […]
SQL Server Newbies
normal role member to be able to view list of other role members in his DB - Is this even possible ? Tried with grant but to no avail. [sys].[database_role_members] and [sys].[database_principals] can not be accessed even with grant .
SQL Azure - Development
How to manage Time zone changes for countries - Hello Everyone, I am using Microsoft SQL Azure (RTM) - 12.0.2000.8, as of October 2, 2024. This software is copyrighted by Microsoft Corporation in 2022. We have developed a ticketing system currently used by around 30 countries, and we expect this number to grow in the coming days. To maintain each country's local time, we […]
SQL Azure - Administration
Azure elastic job issue authenticating to Azure SQL database - Azure elastic agent jobs: I’m getting this error “The server principal “ac1971e9-381b-449b-9e1a-9cc276fc2985@b5313c9d-fb0d-47af-bc87-7c050bffbdc3” is not able to access the database” when an elastic agent job tries to run against a new database that has been added to an elastic pool.   The elastic pool is configured as a target group member. For all other databases in […]
Connecting
SSMS 20.2 on Windows11 not able to connect to SQL 2005 ?? - We still have a couple of dino's. What should I check to re-enable access to ye good old SQL 2005 on Windows 2003 for my SSMS 20.2? I have already accepted "use server certificate" and "optional encryption" Still doesn't work; "SSL Connection forcebly closed by server" btw: When using SSMS 18.12.1 it works fine
Integration Services
Package to Project model conversion - Hi All, With previous customer range we were always required to work in the traditional package model approach were individual packages were stored in deployment folders and combined with configuration files. (Usually old 2008R2 SQL server versions) For my current employee I have the liberty to setup everything from scratch using newest versions of everything. […]
SQL Server 2022 - Administration
Converting job_id to join to another table. - I need help, please! I have a monitoring table that pulls in information about program name (plus sp_who2 does as well), and I need to join it to msdb.dbo.sysjobs to get the job name where the program name starts with SQLAgent (like SQLAgent - TSQL JobStep (Job 0x8FA89775AAF135499FA4CC1621B639FB : Step 1)). Nothing I try is […]
How much transaction logs generated by hourly/daily - For MSSQL is there any queries or methods for me to pull historical data of transaction logs generation? I know that for Oracle database we can run a query to extract the amount of archivelogs generated hourly/daily. Is it possible for MSSQL? I have an hourly TLog backups running on the database, so currently I'm […]
SQL Server 2022 - Development
Compare rows within the same table - I have a table. Structure in script below. I have to compare and see if for a job id if the order of taskname is first 'Print' and then 'Distribute' based on the PrintDate column. I have to select rows where the  'Distribute' is coming BEFORE the 'Print' task based on PrintDate column (eg: JobID […]
A Design Question using a fictious example - Background: I have two tables. Tests and Grades. For each Tests record there are many Grades; one for each student. The Grades table has a field called: StudentsGrade. Each time a Tests record is inserted into the database, an associated Grades record is inserted into the database, one for each student where the value of […]
Generating (semi-)fake purchase data - I know how to generate fake data (thanks to Jeff Moden's articles!)... the problem is that I'm trying to generate purchase data where the unit price of a product increases on some products over time.  Normally, I'd get the changing price information from all the purchase invoices, but I don't have those. So I have […]
 

 

RSS FeedTwitter

This email has been sent to newsletter@newslettercollector.com. To be removed from this list, please click here. If you have any problems leaving the list, please contact the webmaster@sqlservercentral.com. This newsletter was sent to you because you signed up at SQLServerCentral.com.
©2019 Redgate Software Ltd, Newnham House, Cambridge Business Park, Cambridge, CB4 0WZ, United Kingdom. All rights reserved.
webmaster@sqlservercentral.com

 

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -