Questions tagged [sql-server]

Microsoft SQL Server is a relational database management system (RDBMS). Use this tag for all Microsoft SQL Server editions including Compact, Express, Azure, Fast-track, APS (formerly PDW) and Azure SQL DW. Do not use this tag for other types of DBMS (MySQL, PostgreSQL, Oracle, etc.). Do not use this tag for issues on software and mobile development, unless it is directly related to the database.

0 votes
0 answers
20 views

How can I return the Maximum Letters for a particular location using SQL?

I have the following table: I have the following SQL code which isn't working: SELECT MAX(SUM(case when Type = 'email' then 1 else 0 end)) AS 'MaxEmails' FROM Tickets AS T INNER JOIN Officers AS O ...
user avatar
  • 55
0 votes
0 answers
15 views

SQL Server 2014 Convert Column Values into comma separated str

I have a table #f with the following data ID Number V2 28 V2 29 V2 30 I would like my desired output to have ID Number V2 28,29,30 How could I achieve this ? I've tried using the STUFF ...
user avatar
1 vote
0 answers
17 views

SQL Round Seconds on Column to 00 seconds [duplicate]

what's the best way to change seconds and set them 00 on my column like 2020-07-01 14:15:23.000 2020-07-01 14:15:00.000 I want to round datetime 2020-07-01 14:15:23.000 to 2020-07-01 14:15:00.000 ...
user avatar
-2 votes
0 answers
24 views

Using RegEx in SQL Server queries [closed]

I have a table of messages and the variety of messages is huge. The messages have different variables in it such as IP Address and usernames, however a lot of messages have a similar structure. I ...
user avatar
0 votes
1 answer
15 views

Re-connect to SQL Server database after SQL Server 2014 reinstallation

Please excuse my ignorance as I have not had to do this before. The C: drive on our server failed yesterday (Microsoft Server 2012 R2) taking with it an installed instance of SQL Server 2014. Luckily, ...
user avatar
0 votes
0 answers
30 views

SQL double group by

I need to select employees' names from those who has sold products, for the biggest total sum of money in each of the years, in Northwind database. I've managed to create a valid query like this: WITH ...
user avatar
0 votes
1 answer
14 views

How to iterate PYODBC variable multiple times?

I am querying a SQL Server table from Python like following: query = "SELECT PN, PD, VT FROM inpat" data = cursor.execute(query) Next, I am iterating data like following for i in data: ...
user avatar
0 votes
0 answers
18 views

SQL Server : update column based on sum of other columns

Let's say I have table T1 with three int columns, A, B, and C. I need to update column C after the update of both columns A and B. This can be done by: declare @one = (select col1 from T2) update ...
user avatar
0 votes
0 answers
12 views

Create Hierarchical Tree from 2 Columns in SQL

I am having a large set of data in 2 columns where I need to create hierarchical structure from it. Below is the input table structure. ID Parent Child 1 AB1/XY/50/76/1-K-CC24 ...
user avatar
  • 55
0 votes
1 answer
35 views

SQL STUFF FOR XML with specific grouping

I'm working in SQL Server 2014, and I have the following simple data, which tracks calling history of users: PhoneNumber Activity ActivityDate ------------------------------------ 9075551234 ...
user avatar
0 votes
0 answers
15 views

Tsqlt tests are failing even though Expected and Actual tables have same values

I am getting error failed: (Failure) Unexpected/missing resultset rows! for tsqlt tests even though Expected and Actual table has same result volume 90Dayvolume Relative90Dvol 4493 16413368.1429 95....
user avatar
  • 41
0 votes
0 answers
19 views

Insert Large CSV file into SQL table using C# for import and manipulation

Looking for some help regarding a C#/SQL project that I'm working on. I have a csv file with ~14 millions intervals. Here is a header and a sample row File 1 - F1 SENSORID,EXTSENSORID,READTS,VAL ...
user avatar
  • 1
0 votes
1 answer
21 views

How to get the start and end of Fiscal Year in C# based on current date? - Using SSIS Script Task

I created an SSIS Package that reads through existing files and makes changes/moves based on the file names and sheets. I have a C# Script Task that a co-worker wrote which is manually updated for the ...
user avatar
-2 votes
1 answer
29 views

SQL convert Rows to columns without pivot

I have seen several posts on this many of which suggest Pivot. That might be a good solution but my SSMS is 2016 which dose not support Pivot. I am trying to mimic a MS Access report that used VBA to ...
user avatar
0 votes
0 answers
28 views

My string comparison doesn't work with hidden ascii characters

I'm trying to compare the concatenation of two strings like this: SELECT TestChemicalName, ResultChemicalName, CASE WHEN LAB_TestChemicalName + LAB_ResultChemicalName = TestChemicalName + ...
user avatar
  • 5,712

15 30 50 per page
1
2 3 4 5
21458