Here's a few of the new posts today on the forums. To see more, visit the forums.
|
SQL Server 2017 - Development |
Recursive CTE vs UNION ALL in a VIEW - Hi, I'm trying to improve a VIEW which is made of several UNION ALLs, something like this: SELECT 0 as OPNR, nivdop1.nr as DOPNR, 0 as ANTL, (nivdop1.ANT) / sumniv1.SUMANT as ANT, 0 as ANTS, nivdop1.SVIND, nivrv1.nr as RVNR, nivrv1.NAVN as RVNAVN, nivrv1.TYPE, 1 as NIVEAU, 0 as PARENT, nivdop1.LINE, 0 as PLINE from DBDOPSK […] |
How to preserve leading zeros with insert into - Below is the create table script and the insert into statement. Both work fine in SSMS. However, the insert into drops my leading zeros. These are important because I have a query that I want to test out that clearly specifics certain character counts and values. I am hoping to […] |
FUN only, solving a Puzzle. - /* For FUN. I like puzzles, I like T-SQL coding, I like to show off :-), so why not combine these. This project was for FUN only, but I did learn new things. Goal: Build a Sudoku solver with the minimum amount of script. (Minimum number of lines or characters). It does have to solve […] |
SQL Server 2016 - Administration |
Update Statistics is causing DB file to grow in always on envrionment - Hello! When I check what is causing DB files (.mdf) to grow, it is showing as Update Statistics. DB files are auto-growing by 1 GB. In about a month, it has grown by more than 10 GB. Could you please let me know the reason and how to prevent it from this? Thanks in […] |
Looking for recommendation on "cost threshold value" - H All, What is the recommended value for setting sp_configure setting "Cost Threshold For Parallelism" for an OLTP workload instead of default value 5? Regards, Sam |
SQL Server 2016 - Development and T-SQL |
Workaround for executing dynamic sql in function - I'm trying to create a view which dynamically generates text from input parameters. But executing dynamic sql or stored procedure is not allowed in functions. Is there a work around for this? Below is sample script for: 1. Create tables, 2.Create function, 3.Create view, 4. Expected output ----------------TABLES------------------------- IF OBJECT_ID('dbo.emp_info', 'U') IS NOT NULL DROP […] |
SQL server change table query not working as expected - Hi, It looks like that a CHANGETABLE query for a particular table is not working correctly. I created a record in the bill_details table and then updated it. The record was created with sys_change_version=5000. The records was updated with sys_change_version=5001. But the following CHANGETABLE queries are confusing me and apparently returning incorrect sys_change_creation_version: select * […] |
Administration - SQL Server 2014 |
Trying to determin how much space I have a left on my server - Hi, The issue, I inherited, is that I have a 2012 SQL Server installation siting on a Win 10 machine; not sure if that matters. The C drive 93.6 GB free, and I can find how much space is allocated on each of my databases. I know there is a lot to look at such […] |
SQL 2012 - General |
tempdb shrinking - Hi, Need some quick help here. I am unable to shrink tempdb files. There is lot of available free space. DBCC loginfo output We have an alert and incident opened for this and we have to close it. Other thing is that systems/storage team is not going to give us more space. There are […] |
Convert column values into single row comma separator - Team My requirement is to convert column values into single row comma separator along with single quotes. Pls help ServerName > Column Name Values in a row like below Server1 server2 server3 server44 I need a result like 'Server1,server2,server3,server44' |
SQL Server 2019 - Development |
Query to fetch quarter & year from date - Hi, I am having the following query to fetch day & year of a particular date. Need to fetch Quarter & Year also. I tried in a similar fashion. But its not working. Please help on this. DECLARE @minDate_Str NVARCHAR(30) = '01/01/2020' , @maxDate_Str NVARCHAR(30) = '31/12/2020' DECLARE @minDate DATETIME, @maxDate DATETIME SET @minDate = […] |
Running VBS Script through SQL Agent Job - Hello All, Glad to have found this board. I have a VB Script that is exporting a query to an excel file. It works perfectly when I run it from the command line. When I create a SQL Server Agent Job to execute the same script, it fails. The type is 'Operating System (CmdExec)' and […] |
T-SQL (SS2K8) |
How to extract the right country info from the field? - This is very painful to me, I have a list of location and need to determine as much/close as possible(no need to be 100% accurate) for its country info, sample as below and two files attached here: one has 100 records, the other is the full list. San Diego, CA, United States Chicago, IL, United […] |
Reporting Services |
SSRS report rows not summing correctly - Hi, I have produced a report in report builder. During the month the report runs ok, however when the report crosses into a new month e.g. January to February, it seems to split on the number of referrals whereas it should be a total number. Within my SQL code it shows the split with the […] |
General |
SELECT different rows on multiple threads - I have an application which will be reading from a single table, in order to speed up the processing of each row it will run multiple threads, as soon as each thread finishes it will read again from the same table. My first approach is to select the rows assigned to an index of each […] |