4,589 questions with Transact-SQL-related tags

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

Parameter or variable has an invalid data type

Hello, Spent few hours searching for a solution but totally stuck building the procedure and getting the error: "Msg 2715, Level 16, State 3, Procedure sp_merge_Clv_ProductsAll, Line 3 [Batch Start Line 0] Column, parameter, or variable…

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-09-01T23:33:23.207+00:00
braxx 436 Reputation points
answered 2020-09-02T09:17:19.573+00:00
braxx 436 Reputation points
2 answers One of the answers was accepted by the question author.

Can i do http request via the custom function which created by clr?

Can i do http request via the custom function which created by clr?

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-09-01T14:59:17.37+00:00
mitaraiqueen 21 Reputation points
accepted 2020-09-02T07:08:42.297+00:00
mitaraiqueen 21 Reputation points
4 answers

Query for estimating the table or the database size - SQL Server 2014-2016

Hi, in order to request the right storage for a database, I need to estimate the related size before to feed it. This database has many tables and each table has int columns, smallint columns, nvarchar columns, nchar columns and so on. Does it…

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-31T12:37:54.18+00:00
Pasquale Massimo Scorca 1 Reputation point
commented 2020-09-02T06:40:31.46+00:00
MelissaMa-MSFT 24,176 Reputation points
5 answers

How to include update stmts with Control expressions?

Hello There - I have a query that selects into a sql statement and then have bunch of updates.. i am trying to use cte but not sure how to add multiple update stmts after the cte. Do we use comma after each Update or? Any help is appreciated. Is the…

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-27T15:18:26.79+00:00
Remo522 21 Reputation points
commented 2020-09-02T06:38:49.913+00:00
MelissaMa-MSFT 24,176 Reputation points
2 answers One of the answers was accepted by the question author.

Query to find list of all primary keys and check if they are clustered and if they are on uniqueidentifier column

Dear Experts, I have this requirement to query all the tables in my database to check if the tables have clustered indexes on the primary key and if the key column is an uniqueidentifier. I prepared this script below select o.name as TableName ,…

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.
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-09-01T11:16:02.677+00:00
mo boy 396 Reputation points
commented 2020-09-01T13:01:50.353+00:00
Dan Guzman 9,221 Reputation points
6 answers One of the answers was accepted by the question author.

How to get missing parts on trade code table and that exist on table #parts and #search data?

I work on SQL server 2012 I need to count missing rows Part id that exist on table #parts and not exist on table #tradecode create table #searchdata ( plid int, codetypeid int ) insert into #searchdata (plid,codetypeid) values …

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-31T01:39:54.81+00:00
ahmed salah 3,216 Reputation points
accepted 2020-09-01T08:35:01.4+00:00
ahmed salah 3,216 Reputation points
2 answers

SUM and JOIN 2 columns with different tables but it duplicates results

Good day! Need help re SUM and JOIN 2 columns with different tables but it duplicates results here's the sample data tables; here's my sql query code SELECT MAX([BBI$Transfer Shipment Line].[Transfer-to Code]) AS [Loc Code] …

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-28T07:28:26.103+00:00
glennyboy 121 Reputation points
commented 2020-09-01T07:37:45.653+00:00
Viorel 114K Reputation points
4 answers

When group value based on feature and part some times come left and some times come right why and how to solve issue

I work on SQL server 2012 my issue here is when I use only one part then value become 32BIT 1 when may be 10 part then value become 132BIT meaning cell have two value 32 and 1 some times 1 go to left and some times go to right I need to know why…

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-24T07:48:02.313+00:00
ahmed salah 3,216 Reputation points
answered 2020-08-31T19:42:34.197+00:00
Tom Phillips 17,721 Reputation points
2 answers One of the answers was accepted by the question author.

Display all employee.

Below is data and query attached21355-q.txt, i want to display all employee from #tbl_employee_Master ,but asd.sal_ID is null from #tbl_assign_Allowance_Deduction ,means that emp_ID exit or not in #tbl_assign_Allowance_Deduction 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.
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-30T08:44:21.753+00:00
Analyst_SQL 3,551 Reputation points
commented 2020-08-31T09:40:48.077+00:00
Analyst_SQL 3,551 Reputation points
3 answers

Querying SQL Server 2012 Training Kit

Apologies in advance, this is very new to me. My boss wants me to start learning SQL queries to assist with reports at work, and the company uses SQL Server 2012. I've been given the Querying Microsoft SQL Server 2012 Training Kit book (textbook and…

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-27T12:18:13.17+00:00
AmyKernow 1 Reputation point
commented 2020-08-31T09:03:40.997+00:00
EchoLiu-MSFT 14,576 Reputation points
4 answers One of the answers was accepted by the question author.

How to update table field if duplicate records found

i am storing line item and xfundcode in a db table. some time line item and xfundcode is repeatedly stored in table. so i want to execute a query which will find duplicate records based on line item and xfundcode and set empty value to xfundcode from the…

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-29T18:55:29.36+00:00
Sudip Bhatt 2,271 Reputation points
accepted 2020-08-31T08:50:03.147+00:00
Sudip Bhatt 2,271 Reputation points
2 answers One of the answers was accepted by the question author.

How to update duplicate records using partition by without using CTE

WITH Dups AS ( SELECT *, ROW_NUMBER() OVER (PARTITION unqiueColumns ORDER BY whateverOrder) AS RN FROM yourTable ) UPDATE Dups SET uniqueColumns = uniqueColumns + CAST(RN AS VARCHAR(255)) WHERE RN > 1

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-29T19:48:43.847+00:00
Sudip Bhatt 2,271 Reputation points
accepted 2020-08-31T08:48:03.743+00:00
Sudip Bhatt 2,271 Reputation points
4 answers One of the answers was accepted by the question author.

How to select statment to data dividing to 3 parts of rows ?

I have table have 6000 rows to books data table without Id I need to display data dividing to 3 parts from 1 to 2000 from 2001 to 4000 from 4001 to 6000 so how to do that please ? create table #books ( ISBN nvarchar(100), Author…

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-19T00:31:22.713+00:00
ahmed salah 3,216 Reputation points
accepted 2020-08-31T07:04:08.033+00:00
ahmed salah 3,216 Reputation points
2 answers

How to decide SQL server 2017 License ? What is user means ? If I use only sa user from application user access then shall I need to purchase that SQL user license ?

How to decide SQL server 2017 License ? What is user means ? If I use only sa user from application user access then shall I need to purchase that SQL user license ?

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-29T13:03:57.127+00:00
Goutam Kumar Das 1 Reputation point
answered 2020-08-31T05:45:22.817+00:00
m 4,271 Reputation points
3 answers

How to upgrade SQL Server 2012 to SQL Server 2017, shall I need to purchase 2017 License.

How to upgrade SQL Server 2012 to SQL Server 2017, shall I need to purchase 2017 License.

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-29T13:01:15.377+00:00
Goutam Kumar Das 1 Reputation point
answered 2020-08-31T05:18:28.68+00:00
m 4,271 Reputation points
1 answer

Sql server 2019

Wanted to migrate SQL 2012 databse of size 60 gb to SQL server 2019 Wanted to know what is the memory required for 60gb database .db server is standalone. As there are more than 20000 users will acces the application daily basis. Db Server is on…

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-27T19:16:48.993+00:00
Ravi Shah 1 Reputation point
commented 2020-08-31T01:12:38.083+00:00
Cris Zhan-MSFT 6,611 Reputation points
1 answer One of the answers was accepted by the question author.

Allowance and Deduction amount set in one row ,against each employee

Below is my query ,i want to set allowance and deduction in one row of each employee,employee ID,must not be repeated again,as you may see in image ,that employee ID 30007 is repeating again. ![SELECT (M.Emp_ID) as ID , M.EMp_Name as Name ,…

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-29T12:31:50.107+00:00
Analyst_SQL 3,551 Reputation points
accepted 2020-08-30T06:48:27.807+00:00
Analyst_SQL 3,551 Reputation points
10 answers One of the answers was accepted by the question author.

Improve the execution time for a complex SQL Query from 25 seconds to be under 1 second in SQL Server Enterprise 2019

How can I improve the execution time for a query where the initial Rows in the view were: 16000 and the query worked resonable ( under 1 second ), but now there are : 42487 rows in the View and the execution time is over 25 seconds ... which is not…

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-24T15:44:09.817+00:00
Lucian Parvu 21 Reputation points
accepted 2020-08-28T11:22:09.907+00:00
Lucian Parvu 21 Reputation points
2 answers

SQL File Tables

Hello team, We are planning to use SQL FIle table. I ahve two queries 1.Can we overwrite the file in a directory using update sql script. If yes, please help me with script We will use this file table to read and write the contents of file in net…

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:45:48.73+00:00
Athulya Pillai 46 Reputation points
commented 2020-08-28T07:57:07.777+00:00
EchoLiu-MSFT 14,576 Reputation points
1 answer

Where is the incorrect brackets

Apparently my bracketing is incorrect, new to adding constraints CREATE TABLE [dbo].[TestCasesIdentifier2]( [TestCaseIdentifierId] [int] IDENTITY(1,1) NOT NULL, [TestCaseId] [int] NOT NULL, [TestCaseSequence] [int] NOT NULL, [FieldName]…

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:03:21.257+00:00
Simon Evans 81 Reputation points
commented 2020-08-28T07:56:18.663+00:00
EchoLiu-MSFT 14,576 Reputation points