Connect to on-prem sql server using Azure Relay
Hi, I would like to connect to a on-prem sql server and execute T-SQL commands to listen and receive SQL broker messages from Azure cloud hosted .net application. How can i connect to on-prem sql server and execute these sql commands and receive the…
Delete query throws "semaphore timeout period has expired"
Hi All, I'm running a delete query as part of purge activity. The delete query has about 12+ foreign key constraints, and when we try to delete 1300 records as per our condition we get the below error. The table has about only 15K records and the db…
Complex Pivot using the existing data
--ALTER PROCEDURE Energy.GetGTSTDataForManualEntry --( -- @Date DateTime -- ) --AS BEGIN DECLARE @Date DateTime = '2024-03-29 00:00:00.000'; DECLARE @CalendarID INT = Time.GetCalendarIDByLocationCode('Energy'); DECLARE @DayPeriod…
Oracle Connector on Polybase
Hi everyone, I currently have Polybase (SQL Server 2019 RTM) that connects to Oracle database. This was working well untill the Oracle database was upgraded to 13c and I started getting this error: TNS: Listner could not resolve SERVICE_NAME…
Convert 14 Char String to Datetime
I have a field in a table called TraceID that stores data like this: 2024040611102200021 The first 8 characters represent the date (YYYYMMDD). The next 6 characters represent the time (HHMMSS). The last five are insignificant numbers. So this would be…
Transpose column to rows
Hi, Without using a cursor (if poss) I would like to turn the following data into rows based based upon the integer in column two. So I would end up with 5 rows for the first date, 1 for the second etc. Can anyone advise on how best to do this pls?…
SQl Server Agent "Unexpected Termination" with no error details
Hi, I have built an SSIS project where one main package refers to and carries out over 30 other packages in succession. Each package does the same job - uses an excel sheet as a source to then update the same data stored in a SQL Server database…
DATEDIFF (YEAR, StartDate, EndDate) returns incorrectly
I am trying to figure out why the DATEDIFF(YEAR) Function is returning incorrectly and am wondering if I have to get the StartDate and EndDate in a certain format before attempting to use the function. SELECT DATEDIFF(YEAR, '2023-12-31 08:31:42.373',…
display rtf saved in the database with proper format in react app
I have c# desktop application using the Microsoft's built in Microsoft Rich Textbox Control and we have used it to save the rtf in mssql database. now i do want to display the rtf fetched from the database to be displayed in my react application with the…
The MSSQLSERVER service terminated unexpectedly
Dear All SQL expert, Do you know what is the case that make The MSSQLSERVER service terminated unexpectedly? Recently, The SQL server (MSSQLSERVER) and SQL Server Agent are stopped automatically during running import data to sql server. We are using…
Azure SQL Database large tables performance Issue
In my Azure SQL Database, there exists a considerably large table, let's call it 'tableA'. In my application, I have several distinct queries (approximately 10) that involve different sets of columns from this table. For example, 'query1' utilizes…
Rewriting an Oracle procedure with cursor in a T-SQL procedure
Hi, I need to rewrite an Oracle procedure that uses heavily a cursor in a T-SQL stored procedure. An Oracle cursor is an object more efficient/performant than a T-SQL cursor and moreover the Oracle procedure logic works row by row and has several IF ...…
has inline function got any catch?
hi, I heard many people saying "functions are denounced in tsql" is there any catch? q1) need to know what are the cases where we should not use? q2) should we avoid scaler functions also? q3) should we avoid scaler functions if we have to…
SQL Server : Get size of all tables in database
The above sql works fine but i want the size in KB OR MB OR GB at the end i want a new column which show total size like TableSizeInMB+IndexSizeInMB KB OR MB OR GB ;with cte as ( SELECT t.name as TableName, SUM (s.used_page_count) as…
I would like some advice on how to use a query to get the total size of each disk drive.
When I try to get the total size of each disk drive using sp_OAGetProperty in mssql, I cannot get a value greater than 17,592,186,040,320 for large drives. I would like to ask for advice on a solution that can be checked using a query. And I don't want…
stored proc
Hello, I have a stored procedure which does the following: 1- filter tables and place data into #table1 2- filter tables and place data into #table2 ... Then at the end of the stored proc, select columns by joining these #tables. I have several stored…
Statement causes error
Dear All, What's wrong with the statement "create index engnamestuid on engname + cast(student as nvarchar(6))"?
slow execution WHEN update chemical id on table chemicalhash so how to enhance it ?
I work on sql server 2017 i need update chemical id on table chemicalhash based on 3 columns compare to table fmd chemical compare 3 columns strSubstances,strMass,strCASNumber from table chemicalhash with 3 columns strSubstances,strMass,strCASNumber from…
How to get parts from table part and not exist on both tables chemical missing and chemical master ?
I work on sql server 2012 i need to get parts from table part and not exist on both tables chemical missing and chemical master by using exist or not exist and if there are more ways please help me I need to rewrite these statement with another…
SSRS Dataset using #Temp Tables
I could have sworn I have done this before. I have multiple Datasets in my SSRS .rdl. The first Dataset creates the #Temp Tables which subsequent Sub-Reports and SQL Server Stored Procedures and Datasets utilize. Also, utilizing the Use single…