Microsoft Q&A

4,389 questions

4,389 questions

Sort by: Updated
3 answers One of the answers was accepted by the question author.

How to Convert Date format as an ISO formate in SQL

HI Team, Currently we have Date Data set and need to Convert it to below mentioned format, Could you please Support to Convert into requirement format. Original format - 2020-07-02 03:34:07.353 Current format after used Below Query- - …

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
10,747 questions
4,389 questions
asked 2020-09-08T11:44:13.743+00:00
Mahesh Madhusanka 151 Reputation points
commented 2023-09-01T09:36:37.14+00:00
Jan Kučera 0 Reputation points
4 answers

SQL Query to convert rows to columns dynamically

Dear Friends, May i request you to suggest a way to use SQL code like a look up please? Sample data input : Table A: with 2 columns Identifier_Column, data India,323 India,324 India,325 US,326 US,327 Output :…

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
10,747 questions
4,389 questions
asked 2022-08-18T17:56:03.303+00:00
Krish 81 Reputation points
commented 2023-08-29T20:55:57.26+00:00
Erland Sommarskog 86,061 Reputation points
2 answers One of the answers was accepted by the question author.

SQL Server How to find out who lock my specific table

Here i got the script which showing bit similar output but i want output for specific table. i want to know which query and from which PC lock my specific table. say my table name is tblOutput here is the query which bit close to my requirement. …

4,389 questions
asked 2022-05-09T17:32:51.973+00:00
T.Zacks 3,971 Reputation points
commented 2023-08-27T02:03:49.4333333+00:00
Zubair 0 Reputation points
4 answers One of the answers was accepted by the question author.

Better performance in creating table or renaming schema

I have a requirement wherein i want to move data from staging table to main table Which method would be better in terms of performance: select * into main table from staging table Alter schema of staging table to main table schema

Azure SQL Database
SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
10,747 questions
4,389 questions
asked 2022-08-03T08:06:55.7+00:00
Priya Jha 846 Reputation points
commented 2023-08-21T22:23:38.49+00:00
Cahill, Dana (RIS-ATL) 0 Reputation points
4 answers One of the answers was accepted by the question author.

Failed to initialize sqlcmd library with error number -2147024809.

Hi, I use the following script to send the result of a query as attachment to email. The script works correctly if I delete the argument @Query _no_truncate = 1, instead when I use it the script returns the error in subject. Can anyone help me? …

4,389 questions
asked 2021-04-06T13:13:00.583+00:00
Massimo 21 Reputation points
answered 2023-08-18T19:13:57.9966667+00:00
Scott Minter 0 Reputation points
4 answers

Windows 11 SQL Server install error Wait on the Database Engine Recovery Handle Failed

In Windows 11 Machine, unable to install SQL server 2019. I tried multiple versions. but got the following error message. I tried multiple times and restart the machine. nothing worked out. Please somebody help with this. Edition Windows 11…

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
10,747 questions
4,389 questions
asked 2022-12-27T14:14:32.197+00:00
S Dineshkumar 1 Reputation point
commented 2023-08-12T11:59:55.79+00:00
Erland Sommarskog 86,061 Reputation points
3 answers One of the answers was accepted by the question author.

UNPIVOT Query Fails When A Second Column Name Prefix Is Introduced

Good Afternoon, I am sql server express newbie working with a table that has 250+ columns. Previously, I have used PowerBi to unpivot this wide table to the following four columns: prvdr_num, ffy, attribute, expense which were then imported into ms sql…

Azure SQL Database
SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
10,747 questions
SQL Server Analysis Services
SQL Server Analysis Services
A Microsoft online analytical data engine used in decision support and business analytics, providing the analytical data for business reports and client applications such as Power BI, Excel, Reporting Services reports, and other data visualization tools.
1,155 questions
4,389 questions
asked 2022-04-17T19:46:14.433+00:00
Al C 41 Reputation points
commented 2023-08-10T01:31:11.3633333+00:00
Fabio de Jesus Gomes 0 Reputation points
1 answer

SSMS debugger out of sync with code

This question has been asked before: ssms-debugger-out-of-sync-when-stepping-through-code I have followed the recommendations there but my debugs are still out of step. I ran DROP and CREATE on my SP then stopped and restarted SSMS (2016). I then…

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
10,747 questions
4,389 questions
asked 2022-08-24T20:44:29.67+00:00
Nick Ryan 111 Reputation points
commented 2023-08-09T06:55:11.41+00:00
Patrick Simons 0 Reputation points
6 answers One of the answers was accepted by the question author.

Delete records older than 12 months but the date is in YYYYMM format

Hi, I have a table that gets updated with fresh data every month I am trying to delete records which are older than 12 months (1 year) from my table.(automate through SP to keep only rolling 12 months data), but the problem is the field 'LoadedDate'…

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
10,747 questions
4,389 questions
asked 2020-11-19T20:15:49.497+00:00
jennifer zen 336 Reputation points
commented 2023-07-31T09:07:39.87+00:00
Imanthi Erandi 0 Reputation points
4 answers One of the answers was accepted by the question author.

Check for SQLCMD mode and exit otherwise

We have a problem with DEV's running SQLCMD scripts in SSMS without SQLCMD mode turned on. Code like this (but not this, obvs): use PRODUCTION :`setvar CurrentDatabase "DEVELOPMENT" use [$(CurrentDatabase)] truncate table…

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
10,747 questions
4,389 questions
asked 2022-03-04T14:50:46.613+00:00
Stephen Hulbert 21 Reputation points
edited an answer 2023-07-27T12:20:12.95+00:00
Christopher 0 Reputation points
5 answers One of the answers was accepted by the question author.

How to enable sql query logging

I need to get a list of queries and stored procedures that are run from an sql server for a given date range (usually the last 24 hours) for an auditing company. I am not sure whether this is possible. Would appreciate if any one could help me with how…

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
10,747 questions
4,389 questions
asked 2022-01-21T16:32:56.393+00:00
Don75 81 Reputation points
answered 2023-07-27T09:38:33.7033333+00:00
vijay sr 0 Reputation points
1 answer

Best approach to load data from table with billions rows

Hi - We have a sql server table with over billion rows in it with ID as identity column. I have query that filters the table (source) with certain condition and want to load them in another (target) table (all the columns without ID column from source…

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
10,747 questions
4,389 questions
asked 2021-09-24T15:35:01.077+00:00
RD 1 Reputation point
commented 2023-07-19T14:17:00.8933333+00:00
Lisa Kruger 60 Reputation points
3 answers One of the answers was accepted by the question author.

Execution Timeout Expired. The timeout period elapsed prior to completion of the operation or the server is not responding.

Hi Team, We are getting below error while running query in SSMS: Execution Timeout Expired. The timeout period elapsed prior to completion of the operation or the server is not responding. Normally it shouldm't take more than 2 mins. But from…

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
10,747 questions
4,389 questions
asked 2021-07-07T20:32:35.56+00:00
Vijay Kumar 2,001 Reputation points
commented 2023-07-19T09:29:04.1233333+00:00
Erland Sommarskog 86,061 Reputation points
7 answers

Unable to open the physical file. Operating system error 5: “5(Access is denied.)”

I am trying to work on a query to attach a database (UNC path) remotely. I have SQL Server management studio (SSMS) installed in SQL Server machine (machineSQL) and also in another machine (machineRemote) in same domain. Query:: CREATE DATABASE…

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
10,747 questions
4,389 questions
asked 2020-09-24T01:18:45.57+00:00
Nishant Kumar 1 Reputation point
edited an answer 2023-07-18T06:04:24.8566667+00:00
Ela Salimi 0 Reputation points
2 answers One of the answers was accepted by the question author.

Run sql job with different email addresses from sql table

Hello, I have a sql table with recipient email addresses along with unique id, names etc.. How would I run a sql job to send HTML formatted email (includes table data) to different recipients from a table. It should start from row 1 until it reaches…

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
10,747 questions
4,389 questions
asked 2021-06-08T08:44:39.467+00:00
DBA9 21 Reputation points
commented 2023-07-13T09:38:40.0733333+00:00
Sandy Zimmer 0 Reputation points
2 answers

Replace NULL in a ROLLUP

Hello, I would like to replace the NULL in the final row when using the ROLLUP, for any other word like 'Total'. SELECT SalesOrderID, SUM(UnitPrice*OrderQty) AS Total FROM Sales.SalesOrderDetail GROUP BY SalesOrderID WITH ROLLUP

4,389 questions
asked 2022-05-28T15:05:25.803+00:00
Antonio José Esis Ochoa 6 Reputation points
commented 2023-07-13T01:26:38.8166667+00:00
uzr6bq 0 Reputation points
9 answers

Using TSQL How to Script All SQL Server Agent Jobs into One File

I am trying to find TSQL that will script all the SQL Server Agent Jobs into one File. I haven't found anything yet. Can someone point me to an URL that I can look into? We are uninstalling SQL Server Standard and installing SQL Server Developer,…

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
10,747 questions
4,389 questions
asked 2022-10-07T00:31:29.01+00:00
LauraC 21 Reputation points
commented 2023-07-07T16:24:21.5166667+00:00
mastershake 0 Reputation points
5 answers

How to copy data from Salceforce to SQL SERVER tables

Hello Good Morning, I have tables in salceforce, i would like to copy/load them into sql server daily. (just truncate and reload) in sql server. other than SSIS any other ways? such as salceforce side or any automated ways that you aware of? please…

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
10,747 questions
SQL Server Integration Services
SQL Server Integration Services
A Microsoft platform for building enterprise-level data integration and data transformations solutions.
2,201 questions
4,389 questions
asked 2021-08-03T20:38:27.777+00:00
milan i 81 Reputation points
answered 2023-06-27T10:43:06.93+00:00
Jacob Martin 0 Reputation points
1 answer One of the answers was accepted by the question author.

Correction needed - on Trasact-SQL (Self-contained subqueries) "A self-contained subquery is processed once when the outer query runs and passes its results to that outer query"

Kindly confirm if this statement is correct in below topic "A self-contained subquery is processed once when the outer query runs and passes its results to that outer query" Working with subqueries A subquery is a SELECT statement…

4,389 questions
asked 2023-01-07T05:47:16.893+00:00
David Bungei 21 Reputation points
commented 2023-06-27T02:10:52.58+00:00
Belay Dagne 0 Reputation points
3 answers

Percentage must be 100

Hi, Could you please help me how to get the total percentage as 100% from below dataset through T-SQL? 0.66%, 0.66%, 10.63%, 21.71%, 36.84%, 23.03%, 6.48% -> must be equal 100.00% 0.61%, 0.66%, 10.65%, 21.45%, 36.48%, 23.63%, 6.76% -> must be…

4,389 questions
asked 2021-06-08T22:19:16.55+00:00
Zaran 21 Reputation points
commented 2023-06-26T13:53:06.7033333+00:00
Utkarsha V Sawant 0 Reputation points