4,589 questions with Transact-SQL-related tags

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

SQL Server Agent Weirdness

Hello Running SQL Server version Microsoft SQL Server 2017 14.0.3281.6 (X64) I have a query which when run in SSMS finishes exactly when I want it to, what it does it goes to a different server and checks if a job has completed ether successfully or…

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-25T11:44:20.827+00:00
Peter Nolan 21 Reputation points
answered 2020-08-26T09:42:13.383+00:00
Peter Nolan 21 Reputation points
3 answers One of the answers was accepted by the question author.

Query SQL Error Log with T-SQL

Hi Team, I am treying to query SQL error log using T-sql. There is some issue with T-SQL. I am not getting error logs from last 24 hrs. CREATE TABLE #ErrorLogInfo ( ID INT…

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-21T21:07:24.6+00:00
Vijay Kumar 2,021 Reputation points
accepted 2020-08-26T04:05:46.843+00:00
Vijay Kumar 2,021 Reputation points
2 answers

Why can't I use the Import Data Wizard (on SSMS) to alter the default schema for new destination tables?

Hello, I hope this question is clear. I am still in the process of adding an image of the error message. I am using the wizard to import a flat file source into my database. I have SQL Server Express 2019. My goal is to create a table with…

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-22T02:02:35.43+00:00
hapless 1 Reputation point
commented 2020-08-26T02:09:51.447+00:00
CathyJi-MSFT 21,116 Reputation points Microsoft Vendor
2 answers One of the answers was accepted by the question author.

Create a cursor that update field type char value in Sql Server

Hello , i want create a cursor that update column of my table Schools with more than three levels of education are level A, Schools with two levels of education are leveled with category B and other schools are leveled with category C. I tried…

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-25T00:51:44.173+00:00
jonathas moura 21 Reputation points
commented 2020-08-25T22:07:37.11+00:00
Erland Sommarskog 104.7K Reputation points MVP
2 answers One of the answers was accepted by the question author.

not able to put is equal to sign (=) in query,

When i am inserting is equal sign= in query code sample then sign (=) in query is not showing in preview, what can be the issue

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-22T09:21:16.07+00:00
Analyst_SQL 3,551 Reputation points
accepted 2020-08-25T12:22:24.91+00:00
Analyst_SQL 3,551 Reputation points
2 answers

Convert comma seperate string into individual rows

Hi Team, I have a requirement that need to convert comma separated string into individual records in DB table. Below I mentioned sample data. From below screenshot input columns C3&C4 are independent columns, where as C5& c6 are dependent on each…

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-22T03:00:59.357+00:00
Anonymous
commented 2020-08-25T01:55:43.237+00:00
EchoLiu-MSFT 14,576 Reputation points
3 answers

coalesce error

Hi , It got this error The conversion of a date data type to a datetime data type resulted in an out-of-range value from the statement 1 below. 1: coalesce(e1.[ResDate],e2.[ReDate],case when year(c.mydct)!=1970 then dateadd(minute,-360,c.mydct) else…

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-21T19:35:25.977+00:00
Vicki 46 Reputation points
commented 2020-08-25T01:54:28.6+00:00
EchoLiu-MSFT 14,576 Reputation points
2 answers

Getting error creating view

I am creating a view over multiple tables. I am getting an error on a field that says it's invalid but it does exist in the table. field name is udHCSSE360WO and I have verified the spelling against the table. The same field exists in a different…

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-21T13:22:45.243+00:00
Brenda Stewart 96 Reputation points
commented 2020-08-25T01:53:33.187+00:00
EchoLiu-MSFT 14,576 Reputation points
2 answers

best way to query

Hi, I have the below query.I am passing the param to SP and @month is of yyyy-MM format.Basically whenever the @month is any month other than quarter end month,i calculate value from previous quarter end else i calculate the value for quarter end…

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-20T01:57:31.053+00:00
PV 21 Reputation points
commented 2020-08-25T01:29:47.747+00:00
EchoLiu-MSFT 14,576 Reputation points
3 answers

Why I am not able to restore TDE database?

Hello, I am running into an issue regarding restoring a TDE database and I just keep getting the "thumbprint not found error". I don't know what's causing it. Here are some details. I'm hoping someone can help me. I have many…

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-23T13:02:23.62+00:00
sidney l 1 Reputation point
commented 2020-08-24T13:20:28.797+00:00
sydney 1 Reputation point
3 answers One of the answers was accepted by the question author.

SQL Server Aggregate Query

I need to write a query that returns the ID of the items counted to find duplicates. I have a Transaction table with Procedures and need to find accounts where COUNT(Procedure)>1 GROUP BY Account. That part I can do. I don't know how to return 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-21T14:12:02.877+00:00
SM 21 Reputation points
answered 2020-08-24T09:49:00.597+00:00
EchoLiu-MSFT 14,576 Reputation points
6 answers

Help with Transact SQL

Hello all, I have a table with columns as below DECLARE @meter TABLE (prop_id int, min_calc_date datetime, max_calc_date datetime, fuel_rate int ) INSERT INTO @meter VALUES (123,'01-01-2020','08-19-2020', 50) , (123,'01-01-2020','08-19-2020',…

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-20T20:15:42.217+00:00
Sri Kotte 21 Reputation points
commented 2020-08-24T08:52:02.687+00:00
EchoLiu-MSFT 14,576 Reputation points
5 answers

Select top 1 column along with CSV column

Hi All, I've a table as below: TableId SId Data DataOwner 1 10 aaaa 1001 2 10 aaaa 1000 3 20 bbbb 1000 4 10 ccc 2000 Declare @table1 table(TableId int, SId int, Data varchar(200), DataOwner int) insert into @table1 values(1, 10, 'aaaa', 1001)…

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-20T14:23:47.04+00:00
Bluecloud1921 1 Reputation point
commented 2020-08-24T08:50:43.723+00:00
EchoLiu-MSFT 14,576 Reputation points
3 answers

BCP date format

I am attempting to import data using bcp. The data contains dates formated as Jan 03 2019 12:00:00:00.000000AM. BCP rejects this data, saying this is an invalid date format. I believe BCP expects a date formatted as 2019-01-03 12:00:00:00.000000. …

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-21T03:31:31.837+00:00
Ted Dykhorst 1 Reputation point
commented 2020-08-24T06:42:01.547+00:00
MelissaMa-MSFT 24,176 Reputation points
2 answers

Native Bcp file is converting special characters in the column value

Hi, I am generating bcp file in Sybase ASE with -n (native) and delimiter "|" and trying to load in SQL SERVER 2016. I know native file is not compatible with MSSQL Server . Is there any way or option i should explore to handle special…

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-20T20:25:13.447+00:00
ssalun 26 Reputation points
commented 2020-08-24T06:40:29.3+00:00
MelissaMa-MSFT 24,176 Reputation points
3 answers

Return null values if there is no record for top n selected

I am trying to get the top ‘n’ rows from the following query: SELECT TOP 1 ImageName FROM (SELECT TOP 5 * FROM ClientKeywordMedia where keywordid=1147 ORDER BY ID) z ORDER BY ID DESC The above query is working fine if top 5 is used in subquery as…

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-20T16:40:24.183+00:00
sudhir bharti 1 Reputation point
commented 2020-08-24T06:39:22.577+00:00
MelissaMa-MSFT 24,176 Reputation points
4 answers

Query with Exist

Hello team, I have written a query as below: ;With myCTETable AS ( SELECT ShipCountry, CustomerID, OrderID, OrderDate, Rank() Over(Partition by shipCountry Order by Shipcountry, OrderDate Asc) AS FirstOrderDate From Orders ) SELECT…

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-19T20:00:44.82+00:00
CouldsInSky 41 Reputation points
commented 2020-08-24T06:38:41.953+00:00
MelissaMa-MSFT 24,176 Reputation points
3 answers

Database design for friends relationships

Hallo! Can you help me design database for friends social relations with 1000 requests per second. Bob->Mary John->Bob Serg->Francis Francis->Bob Result: Bob->Francis->Serg 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-18T13:06:15.097+00:00
Ilya Mihaylov 1 Reputation point
commented 2020-08-24T06:36:12.773+00:00
MelissaMa-MSFT 24,176 Reputation points
5 answers One of the answers was accepted by the question author.

Return one record per criteria

Hello folks, I am struggling with a solution for getting one record per criteria. In the attached example, I would like to get one record per "nbr". I have started with this, but obviously something does not work as it should :) SELECT…

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-23T03:48:35.54+00:00
cito80 21 Reputation points
commented 2020-08-23T14:16:14.52+00:00
cito80 21 Reputation points
3 answers One of the answers was accepted by the question author.

Updating a table based on values in the table

I have a temp table #XX that looks like this" ID KWID NAME ORDER 1447 1144 SW_6368_58_55.png NULL 1450 1145 SW_6942_58_55.png NULL 1451 1147 Arb3_43_55.jpg NULL 1452 1147 Arb1_43_55.jpg NULL 1453 1147 Arb2_43_55.jpg NULL 1598 1152…

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-22T00:45:59.007+00:00
Jim Seidel 61 Reputation points
commented 2020-08-22T21:57:34.327+00:00
Jim Seidel 61 Reputation points