4,589 questions with Transact-SQL-related tags

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

Report query reading content from .txt file

Hello everyone. Our company has a list of software which employees can install without previous authorization (Allowed Software) I was asked to create a report listing all the not allowed software installed in the company computers. Let's say our…

Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,589 questions
asked 2020-08-27T06:41:56.923+00:00
Alberto Valdes 21 Reputation points
accepted 2020-08-28T07:55:22.487+00:00
Alberto Valdes 21 Reputation points
3 answers

Pivot table

I have below table structure. Id | Question No | Question | Answer 1 | 1 | Name | John 1 | 2 | Address | Hawaii St 2 | 1 | Name | Doe 2 | 2 | Name | msdn st I have total 5 questions and 5 answers consistently. I'm looking for output in below…

Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,589 questions
asked 2020-08-27T01:28:14.573+00:00
Jayraj Parsa 1 Reputation point
commented 2020-08-28T07:55:11.86+00:00
EchoLiu-MSFT 14,576 Reputation points
2 answers

Criar um cursor que atualiza um campo char na tabela ESCOLA

Olá, estou tentando criar um CURSOR para fins didáticos que atualiza um campo Char na minha tabela ESCOLA conforme a quantidade de níveis de ensino na tabela ESCOLA_NIVELENSINO. Qualquer ajuda é bem vinda pois a ideia é eu fixar bem o conhecimento,…

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
13,164 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,589 questions
asked 2020-08-25T12:04:49.62+00:00
jonathas moura 21 Reputation points
commented 2020-08-28T07:53:54.05+00:00
EchoLiu-MSFT 14,576 Reputation points
3 answers

SELECT statement to fix a date/timezone problem in original data.

An application creates a date in a SQL table that is actually a local timezone, but is stored as UTC in SQL. I cannot change the application to fix this issue. However, I am making a VIEW, and I would like to correct the UTC date into true UTC. …

Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,589 questions
asked 2020-08-24T18:50:59.837+00:00
Rod Martin 136 Reputation points
commented 2020-08-28T07:53:13.497+00:00
EchoLiu-MSFT 14,576 Reputation points
2 answers

Select Data from supertype and subtype?

How i can select data from supertype and subtype in sql server? Any query?

Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,589 questions
asked 2020-08-23T01:19:22.533+00:00
Muhammad Naeem 1 Reputation point
commented 2020-08-28T07:50:26.387+00:00
EchoLiu-MSFT 14,576 Reputation points
1 answer

SQL Server Backup Encryption Details

Hello, The Backup Encryption page mentions AES 256 can be used for encrypting backups. However, it does not go into IV generation, Cipher block mode, or Authentication of backups.…

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
13,164 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,589 questions
asked 2020-08-25T17:16:34.307+00:00
justin 1 Reputation point
commented 2020-08-28T07:38:16.317+00:00
CathyJi-MSFT 21,116 Reputation points Microsoft Vendor
2 answers

How to update status where nothing retturn from select cross apply function?

I work on SQL server 2012 I face issue I can't update status with No data returned where no result returned from select statement cross apply function meaning where nothing returned from select statement then update status to nothing data…

Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,589 questions
asked 2020-08-23T23:26:02.117+00:00
ahmed salah 3,216 Reputation points
commented 2020-08-28T06:30:53.747+00:00
MelissaMa-MSFT 24,176 Reputation points
4 answers

String Change in T-SQL

Hi All, I have a requirement, i want to replace string with id value from another table value. Another table id's: 4698,50470,50490,4698,5047 ID NAME 4698 ABC 5047 DEF 5049 GHI Source String :…

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
13,164 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,589 questions
asked 2020-08-23T09:25:55.697+00:00
BHVS 61 Reputation points
commented 2020-08-28T06:28:56.713+00:00
MelissaMa-MSFT 24,176 Reputation points
3 answers

How to rewrite query to take small time when executed ?

I work on SQL server 2012 it take too much time to enhance it so how to enhance it to take small time how to write query this best enhance to take less time ? it take too much time near to half hour to return 50000 rows execution plan …

Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,589 questions
asked 2020-08-27T14:12:25.687+00:00
ahmed salah 3,216 Reputation points
answered 2020-08-28T06:25:37.29+00:00
MelissaMa-MSFT 24,176 Reputation points
4 answers

How to replace sub string by stuff separated by stick | to separate values?

I work on SQL server 2012 I face issue I can't separate values by stick | using stuff ? meaning i need to replace sub string by stuff and what statement below do as sub string ,type.value and XML path SELECT DISTINCT [InputID],PART_ID,[Vendor…

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
13,164 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,589 questions
asked 2020-08-24T02:46:01.173+00:00
ahmed salah 3,216 Reputation points
answered 2020-08-28T01:33:45.897+00:00
m 4,271 Reputation points
1 answer One of the answers was accepted by the question author.

Query takes long time to run

SQL Server: 2014 Problem: I am running a query that joins 3 views and produces results. Query takes over 8 minutes to run, but it runs without an error and produces correct output. Can you please take a look at my query and tell me why it takes 8…

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
13,164 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,589 questions
asked 2020-08-27T14:38:34.403+00:00
SQLIsGood-7036 176 Reputation points
accepted 2020-08-27T17:55:56.03+00:00
SQLIsGood-7036 176 Reputation points
2 answers

Create SQL functions with parameters

Hello, I have a lot of sql scripts which use functions like "string_agg" and "concat_ws". those funcations are available from sql 2017. now I would like to create some backward compatibility for MSSQL 2016 and earlier. I tried if I…

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
13,164 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,589 questions
asked 2020-08-26T12:11:26.737+00:00
Bart K 1 Reputation point
commented 2020-08-27T10:37:27.927+00:00
Viorel 114K Reputation points
5 answers

Table in sql server 2017 takes alot of time to update/insert few rows

Hello I have a table in sql server 2017 that has around half million records and it is constantly used via website. Select statement are very fast over it or over its views,but update/insert of 1 or 2 rows takes a lot of time sometimes 1 row needs 15…

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
13,164 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,589 questions
asked 2020-08-24T06:59:59.057+00:00
mahag 1 Reputation point
answered 2020-08-27T09:36:13.22+00:00
m 4,271 Reputation points
6 answers

Getting an Intermitent issue with Linked Server between 2 On-premise SQL Servers

Hi All, Every now and then I am getting this issue and not sure where to look into it..? _Master_ODS:Error: SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x80004005. An OLE DB record is available. 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.
13,164 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,589 questions
asked 2020-08-24T03:22:38.75+00:00
Shivendoo Kumar 736 Reputation points
answered 2020-08-27T09:35:47.087+00:00
m 4,271 Reputation points
2 answers One of the answers was accepted by the question author.

Date order wise in Pivot

below is my query their ouput is not coming date order wise Declare @fromdate date = '2020-01-01' Declare @todate date ='2020-01-31' declare @pvtColumns nvarchar(max), @sqlQuery nvarchar(max), @qryColumns nvarchar(max), @totalsExpression…

Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,589 questions
asked 2020-08-27T07:01:04.003+00:00
Analyst_SQL 3,551 Reputation points
accepted 2020-08-27T09:28:41.123+00:00
Analyst_SQL 3,551 Reputation points
1 answer One of the answers was accepted by the question author.

Hash Collision percentage on HASHBYTES SHA2_512

Hello, we are trying to move a large table and want to confirm the varbinary values do not change (or at least capture it if it changes). We plan to use below query: select ID, HASHBYTES('SHA2_512', cast(blob AS VARBINARY(8000))) from BlobTable; I…

Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,589 questions
asked 2020-08-27T07:20:17.623+00:00
Larimore Suanque 41 Reputation points
commented 2020-08-27T08:04:34.787+00:00
Larimore Suanque 41 Reputation points
2 answers One of the answers was accepted by the question author.

why the estimated operator cost of query plan is more than 100 %

Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,589 questions
asked 2020-08-18T02:04:50.097+00:00
Ailsa Ge 41 Reputation points
accepted 2020-08-27T06:14:04.467+00:00
Ailsa Ge 41 Reputation points
2 answers

Source table has primary key and should I need to create in destination table

Hi, I am loading the data from source table to destination table where primary key exists on the source table. My question is do I need to create the primary key in destination table as well? Thanks!

Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,589 questions
asked 2020-08-25T18:07:48.893+00:00
red 21 Reputation points
commented 2020-08-27T05:29:31.483+00:00
MelissaMa-MSFT 24,176 Reputation points
4 answers

Slow query

Hello everyone I have the following query that is taking more than 1 hour to run. SELECT RES.NUM_PROCESS, RES.ID_SYSTEM FROM RESTRICTED_PRECESS RES WHERE RES.ID_SYSTEM <> 'CYFV' AND RES.NUM_PROCESS NOT IN …

Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,589 questions
asked 2020-08-26T17:44:37.563+00:00
Edgar Toia Neto 1 Reputation point
answered 2020-08-27T02:30:49.483+00:00
MelissaMa-MSFT 24,176 Reputation points
3 answers One of the answers was accepted by the question author.

compatibility_level and LEGACY_CARDINALITY_ESTIMATION

Hi everyone, we migrated from sql 2012 to sql 2016 and since then we have been facing some performance issue. We decided to change the compatibility level to 110 (sql 2012) and set the LEGACY_CARDINALITY_ESTIMATION= ON. It helped but then we were still…

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
13,164 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,589 questions
asked 2020-08-26T02:13:54.83+00:00
Rohit Kochar 41 Reputation points
commented 2020-08-26T23:46:16.363+00:00
Rohit Kochar 41 Reputation points