Content
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 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 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. …
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
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? …
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…
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…
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…
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'…
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…
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…
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…
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…
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…
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…
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
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,…
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…
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…
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…