Here's a few of the new posts today on the forums. To see more, visit the forums.
|
SQL Server 2017 - Development |
Data type convert help - Hi Gurus, I am just trying to convert data type on a sql script. ----From this format to and convert(date,a.myDate) between '2020-11-08' and '2020-11-16' ---- To this format (need help on this one with correct syntax) and a.myDate = convert (date, between '2020-11-08' and '2020-11-16') --It works when I don't use 'between' ! and a.myDate […] |
SQL Server 2016 - Administration |
Execute against all databases - Hi Everyone I have the below script which is very useful for single database usage. (Credit to the author) How can I make this execute against all my user databases? Thanks SET NOCOUNT ON SELECT 'USE' + SPACE(1) + QUOTENAME(DB_NAME()) AS '--Database Context' select ' IF NOT EXISTS (select * from sys.database_principals where name […] |
SQL Server 2016 - Development and T-SQL |
Azure Data Studio doesn't yield any results when I run it - Recently I've noticed that Azure Data Studio (ADS) doesn't produce any results when I run it. I'm working on a SQL Script to update some lookup tables. I've been putting in lots of PRINT statements, performing SELECTs at various places, etc. Then when I get to a point of where I want to test it, […] |
Datediff (exclude holidays - no function) - I'm counting the days between two dates using DateDiff. In my query I'm excluding weekends, now, I need to excluded the company holidays. How can I accomplish this without a function and just do it within the query? I have a holiday table that lists all of the company holidays. Calcs. the start date and […] |
Finding number of SELECT statements pr. tabel/view with Query Store - Hi guys. I have a question regarding Query Store. I want to check how much each table is used in my database in order to do some cleanup (number of select statements on tabels and views) Normally i would do this with the Transaction log, but unfortunately I have only set this up to log […] |
SQL 2012 - General |
encapsulating DECLARATIONS, UNION ALL, and SELECTS into CTE - I'm having trouble getting this to fit into a usable CTE (the below is returning the expected data but I need to use it as a CTE for flexibility and OOP)... any clues?: DECLARE @period INT = (SELECT period FROM [a2hr].[payroll].[fnGetPrevPeriodYear](GetDate())), @year INT = (SELECT year FROM [a2hr].[payroll].[fnGetPrevPeriodYear](GetDate())), @PRStartDate Date, @PREndDate Date SELECT top 1 […] |
SQL Server 2012 - T-SQL |
How to get the detailed record and summary value at the same time - there are LineNo, itemNo and qty fields in one table, I want to the accumulative qty (totalQty) for each item and want to the totalqty shown as below picture, I just know one way to get the the result , could you please help me how many ways to get the result, it seems that […] |
SQL Server 2019 - Administration |
Creating a new SQL Server Instance in a Failover environment - I am having a real hard time trying to create a new instance for a database using SQL Server 2019 Failover cluster. I am trying to follow these directions. I am stuck on Step 10 which is Instance Configuration. Normally when I create an instance in a regular SQL Server I just give it an […] |
SQL Server 2019 - Development |
SQL JSON Ouptput - I have table with code type , code & Value. I want out in json like this way. In this example Code type test 1 . I try to do union which not allowing and i dont want to put code type instead i want my own name. { { "Test1" [ { "code" […] |
Sum field with where clause based on a RecordId - I'm going to blush when I hear the answer to this. Think I'm over tired. I made this simple example that hopefully explains my problem. Thanks! DESIRED RESULT (line in italics) 1, 20210806, 200, 0, 0 2, 20210807, 200, 0, 0 3, 20210808, 200, 600, 3 4, 20210809, 200, 0, 0 5, 20210810, 200, 400, […] |
SQL Azure - Administration |
Migration to Azure SQL Managed Instance Business Critical Tier from VM's - Hello All, Currently we are planning to migrate from two production Azure SQL Server VM's to Azure SQL Managed Instance and I was doing some reading on SQL Managed instance Business Critical tier and I had few questions which I would like to ask the experts here. As always appreciate all the inputs. I have […] |
Reporting Services |
Microsoft Visual Studio - Hello, I am using Visual Studio 2019 Reporting Services to generate report. I want to add other Table to my current table. Then I got an error message. Please see attachment and help. Thanks Frank |
SSRS Switch with an Or? - Hello, I've been searching and can't find any answers to how (or even whether) this can be done so I'm hoping a regular here can help. In SSRS I'm trying to build a SWITCH statement that has two options on the result. Something like this: SWTICH( Parameter = 1,"A" OR "B", Parameter = 2,"C" OR […] |
Integration Services |
Create one loop for 27 tables - Hi there, everyone. I know this might sound stupid, but I need to ask it anyway. I have to get data across from one server to another via SSIS. They all use the same logic in that there is a data SQL truncate task, a dataflow task that uses source and destination OleDB. Then there […] |
Performance tuning - We have a SSIS package that runs a web service that is a vendor's API. Basically the process it passes a list of bus routes, and then for each routes, it find stops in routes, calcualte the corners direction, and finally get students' stop detailed information and save in database. so there are a lot […] |