|
|
|
|
|
|
|
|
Question of the Day |
Today's question (by Steve Jones - SSC Editor): | |
Refreshing a View | |
Which of these can I use to refresh the metadata for a view? | |
Think you know the answer? Click here, and find out if you are right. |
Yesterday's Question of the Day (by Carlo Romagnano) |
More OUTER APPLY What does the last query? declare @t table(i int) insert into @t SELECT * FROM (VALUES ('1') ,('2') ,('3') ,(NULL) ) AS V([i]) SELECT t.i ,MSG.msg FROM @t t OUTER APPLY ( SELECT msg = CASE t.i WHEN 1 THEN 'ONE' WHEN 2 THEN 'TWO' WHEN 3 THEN 'THREE' ELSE CAST(1/0 AS VARCHAR(10)) END ) MSG Answer: Zero or some rows returned and the command breaks with 'Divide by zero error encountered.'. Explanation: The first row with an invalid value raise an error: 'Divide by zero error encountered.' and no more rows are returned. The preceding rows with "good" value are returned. APPLY is a useful clause to run a subquery with changing parameters. I use it in 3rd party views to check and invalidate data. Ref: APPLY - https://learn.microsoft.com/en-us/sql/t-sql/queries/from-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 2017 - Administration |
Log Shipping Jobs stop working automatically - Dear Friends, On my Log Shipping configuration , sometimes , more frequently actually, the Backup,Copy and Restore Jobs stop working automatically.. I have to check on them and run manually...and some times the restore has errors which force me to reconfigure it again..Any comments / advises on this will be highly helpful..Thank you. |
Trace Flag 3444 - I just discovered trace flag 3444 set on a SQL 2017 srver, and I can't find reference to it. Has anyone come across this trace flag and what is it used for? Thanks MC |
SQL Server 2016 - Administration |
Vulnerability for ODBC driver 13 - ODBC driver 13 has been highlighted as having a vulnerability, and we have been advised to upgrade this to the latest version on our database server running SQL Server 2016 (SP3-GDR). There is apparently no recent version available for version 13. We already have ODBC driver 17.10.4.1 and ODBC driver 18.2.2.1 installed, so we duly […] |
SQL Server 2016 - Development and T-SQL |
T-SQL to run if in Active Directory Group - So we have a block of code that I only want system account to run.. but if a user is db_owner.. they still need access to run the full proc.. is there a way to check to see if the user is in the correct Active Directory group.. then I can set a flag that […] |
WITH RECURSIVE gives error - WITH RECURSIVE factorial(F,n) AS ( SELECT 1 F, 3 n UNION ALL SELECT F*n F, n-1 n from factorial where n>1 ) SELECT F from factorial where n=1 Error Msg 102, Level 15, State 1, Line 26 Incorrect syntax near 'factorial'. Completion time: 2023-07-07T14:16:59.5379702-04:00 If i remove RECURSIVE option it works fine. |
SQL Server 2019 - Administration |
SSRS Theme Reset In SQL Server standard - We applied a theme to SSRS before a license key was applied. A theme which is not suitable has been set, and unfortuately a standard license key has been applied so i can no longer change the theme. Is am aware that as part of SQL Server Standard you can not set a theme, but […] |
[SSIS Server Maintenance Job] failed - Executed as user: ##MS_SSISServerCleanupJobLogin##. The SELECT permission was denied on the object 'availability_databases_cluster', database 'mssqlsystemresource', schema 'sys'. [SQLSTATE 42000] (Error 229). any help with this will be appreciated! |
SQL Server 2019 - Development |
List Month End Dates Between Two Dates - Hi everyone I am working on a query where I need to list all business month end dates between two dates. The two dates would define the start and end periods but these two dates are dynamically created: DECLARE @START_DATE DATE = DATEADD(YEAR,-1,GETDATE()) DECLARE @END_DATE DATE = GETDATE() I am not sure how to generate […] |
SQL Azure - Administration |
Azure SQL VM Patch installation though Automation account , update management - Hi All, Is it possible to apply SQL cummulatative update and OS CU at time by include the KB details in update management. |
Integration Services |
deploy ssis package to MSDB db in SSIS server using azure pipeline - Has anyone tried deploying ssis to MSDB db in SSIS server using Azure pipeline? I am used to do the file system deployment using Azure pipeline but not to MSDB db. Din't find any good article on this on the internet. |
Design Ideas and Questions |
Thoughts on Database Per Service - Lately we've been asked to create several small databases. These seemed related. When we discussed this with the application developers they sent a link (https://microservices.io/patterns/data/database-per-service.html) that talks about individual services having their own database. The article also talks about schema per service, which is what we are advocating, though there isn't much to be found […] |
Anything that is NOT about SQL! |
Need recommendations on replacing a NAS device for home use. - In my home office (SQL Server DBA, now a 13-year retiree) I have two NAS devices, a D-Link DNS-343 (4x2TB) and a WD EX4100 (4x10TB). I had to take the WD NAS off my surge protectors due to repeated 'power supply failure' notices, and it has worked since with no problem. My Win 10 machine […] |
Administration |
Transaction log BU fails in Maintenance Plan fails when there is no Full BU - I have 3 maintenance plans for full backups, differential and transaction log. The job for log backups fails in when there is no full backup. Which is logical of course. But is there a way to prevent this error from happening? I would like an option that it will not try to backup the log […] |
SQL Server 2022 - Administration |
RAISERROR Serverity 16 Showing in SQL Agent Log - We are evaluating SQL Server 2022 and have upgraded an SQL Server Fail Over Cluster and AG with with CU 4. In order not to run the jobs created by Reporting services on the passive node, we have added a step to check to all SQL Agent Jobs that does a RAISERROR to exit out […] |
SQL Server 2022 - Development |
SQL Server AOAG Add 3 IP's to LIstener with Powershell Script Not working - Team, Why does the below not work? Using parameters for listener name and ip addresses. When i hard code the IP addresses in there it works even with the listener as a parameter . I assume it has to do with the quotes. Any assistance is greatly appreciated. See full section of code not including […] |
| |
©2019 Redgate Software Ltd, Newnham House, Cambridge Business Park, Cambridge, CB4 0WZ, United Kingdom. All rights reserved. webmaster@sqlservercentral.com |