|
|
|
|
|
|
|
|
Question of the Day |
Today's question (by Steve Jones - SSC Editor): | |
The Self Referencing CTE | |
What is returned by this code: DECLARE @n int = 5; WITH cte(F,n) AS ( SELECT 1 AS F, @n AS n UNION ALL SELECT F*n AS F, n - 1 AS n FROM cte WHERE n > 1 ) SELECT F FROM cte WHERE n = 1 OPTION (MAXRECURSION 4) ; | |
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) |
Which Data Comes First? In a SQL Server 2022 database, I run this code: CREATE USER apiuser FOR LOGIN apiuser WITH DEFAULT_SCHEMA=webapi GO ALTER ROLE db_datareader ADD MEMBER apiuser GO CREATE TABLE dbo.Location (locationname VARCHAR(20)) GO INSERT dbo.Location (locationname) VALUES ('dbo schema') GO CREATE TABLE webapi.Location (locationname VARCHAR(20)) GO INSERT webapi.Location (locationname) VALUES ('webapi schema') GO CRE I then log in as apiuser and run this code: SELECT * FROM location What is returned? Answer: webapi schema Explanation: The default schema for a user is checked first, if a schema isn't specified. Then the dbo schema is checked if an object is not found. Ref: No good reference I can find here, but try the code. |
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 |
Syntax issue while trying to create index on filegroup - Ok so this is driving me nuts. My syntax is incorrect on this statement: create index IX_Service_Start_Date ON ivc_cds.CDS_Claim_Header (Service_Start_Date ) WITH (FILLFACTOR = 98, SORT_IN_TEMPDB = ON ) on ServiceStartDatePartitionScheme ( Service_Start_Date ) ON [DefFG] Error: Incorrect syntax near the keyword 'ON'. I'm trying to create the above index on the filegroup DefFG. I've […] |
SQL Server 2019 - Development |
Cannot resolve the collation conflict on Azure between master database and db - We have an Azure datanbase which up to today has been working fine However after our latest deployment, we are unable to run our application connected neither can I connect Azure Data Studio - Profiler to the Azure database. I get the following error message: Cannot resolve the collation conflict between "Latin1_General_CI_AS" and "SQL_Latin1_General_CP1_CI_AS" in […] |
Select from view on FileTable throws error - I have a view that computes some fields, using SubString and CharIndex. When I do a Select *, it works great. When I add some conditions, specifying conditions for the COMPUTED FIELDS, the query bombs claiming that invalid arguments were passed to the SubString function. Those computed fields all get computed correctly - there […] |
SQL Azure - Development |
Database Snapshot Alternative in SQL MI - Hi, Database Snapshot feature is not supported in SQL MI. Is there an alternative for having point in time readonly copy in same SQL MI. |
Reporting Services |
SSRS 2019 not able to setup URL Reservations with port 443 - HI . here is the setup i have - Windows Server 2022 and SSRS 2019 i setup IIS and setup a test site using the SSL cert and that is working fine and since have disabled it i am trying to setup SSRS 2019 to work with HTTPS and it doesn't want to work for […] |
'see' and edit text box items when they are obscured by other items - Really new to SSRS Report builder and no training. I have different items and backgrounds that have visibility dependent upon query fields. This means that the items are layered and have differing parent items. I can tab through all the items and adjust their properties but, when it comes to text boxes, I need to […] |
Dynamically generate a new instance of a subreport for every selected parameter - Hello. I have 2 parameter fields I'm passing through to a sub-report to get it to populate. They are 'Year' (only 1 selected) and 'ID' (multiple selected). I'd like to dynamically generate a new instance of the sub-report (aka, template) for each selected parameter. For example... Let's say the ID's selected are "1,5,13' and the […] |
General |
Unintended consequences (Oh sh!t moments) - I firmly believe that one characteristic of good developers is understanding and being able to anticipate unintended consequences. Today I experienced this in a fairly inconsequential thing, but my analytic mind took over. I was entering an order for K-cups on the Keurig website, and got an error when finalizing the order saying my Mastercard […] |
Strategies and Ideas |
Hash value in a primary key? - Hello, Problem: in a dwh table, we are getting duplicates based on some fields that represent the primary key of a table, but this is not a true duplicate cause one of the fields come with lower/upper case, and should be considered as sensitive, the issue is that our database is insensitive case so we […] |
Contests! |
SQL Server 2024 or 2025? - Take a guess when the next version of SQL Server will release. Give me a date, and I'll send a prize to whoever is closest (or maybe 2 people that are equidistant), and posted earliest here. To make it more interesting, if you post in 2023, you get leeway of a week. If you post […] |
PostgreSQL |
TSQL To Postgres - Unpivot/Union All - I am trying to convert this TSQL:INSERT INTO temp_FieldFlowsFact SELECT [Account],[Calendar day],[Financial year],[Period] ,CASE WHEN [Metric] like '%R12M%' THEN 'R12M' WHEN [Metric] like '%R6M%' THEN 'R6M' WHEN [Metric] like '%R3M%' THEN 'R3M' ELSE 'Periodic' END AS [Period type] ,[Metric],[Metric Value] FROM ( ----Calculating Rolling FTRs SELECT [Account], [Calendar day] ,[Financial year],[Period] ,[Issue] ,SUM([Issue]) OVER […] |
TSQL To Postgres - Unpivot/Union All - I am trying to convert this TSQL:INSERT INTO temp_FieldFlowsFact SELECT [Account],[Calendar day],[Financial year],[Period] ,CASE WHEN [Metric] like '%R12M%' THEN 'R12M' WHEN [Metric] like '%R6M%' THEN 'R6M' WHEN [Metric] like '%R3M%' THEN 'R3M' ELSE 'Periodic' END AS [Period type] ,[Metric],[Metric Value] FROM ( ----Calculating Rolling FTRs SELECT [Account], [Calendar day] ,[Financial year],[Period] ,[Issue] ,SUM([Issue]) OVER […] |
Job Postings |
SSRS Contractor Needed - Hello, I have someone who has reached out to me in need of a contractor to build out their SSRS environment and make changes to a dashboard I gave them that we use at my current employer. They are also looking for someone with Power BI knowledge that can help them link their on-premises SQL […] |
SQL Server 2022 - Administration |
Kerberos Configuration Manager connection error with SQL 2022 - Hello experts, I'm trying to use Kerberos Configuration Manager on an instance of SQL Server 2022 and get this error when I try to connect: "Error Unable to connect to server, please ensure that the server name is correct, SQL Server is installed properly, and the user has administrator permissions. If the problem persists, please […] |
SQL Server 2022 - Development |
How to import csv file into a sql table and include filename - Hi everyone, I have a directory of many csv files such as C:\Temp\NP-001.csv C:\Temp\NP-002.csv C:\Temp\NP-003.csv In each csv file, there are 5 columns: Name, DOB, MemberID, Address, Email We need to somehow loop through each csv file and bulk insert or openrowset information to a sql table. The final result would be like a sql […] |
| |
©2019 Redgate Software Ltd, Newnham House, Cambridge Business Park, Cambridge, CB4 0WZ, United Kingdom. All rights reserved. webmaster@sqlservercentral.com |