97 questions with SQL Server Transact-SQL tags

Sort by: Updated
0 answers

How to get a date of day in current week

Hi, I have table that stores configurations like In my sql code, I need to take currentDateTime and get current week date for Execution Day which is Wednesday. So, for this week, it will be 10-02-2024. Get following week wednesday date. Here it…

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,770 questions
SQL Server Transact-SQL
SQL Server Transact-SQL
SQL Server: A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.Transact-SQL: A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
97 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,637 questions
asked 2024-10-02T17:24:40.53+00:00
Spunny 326 Reputation points
commented 2024-10-02T18:47:00.79+00:00
Erland Sommarskog 111.1K Reputation points
1 answer One of the answers was accepted by the question author.

better query for select results based on date.

What is the best way to write this code to get the date results? I have the time throughout the day in the datetime field. SELECT * FROM Reconciliation.Documents D Inner Join Reconciliation.DocumentsTransaction T ON D.DocumentPKey = T.DocumentPKey WHERE…

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,770 questions
SQL Server Transact-SQL
SQL Server Transact-SQL
SQL Server: A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.Transact-SQL: A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
97 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,637 questions
asked 2024-09-30T19:03:37.35+00:00
Jonathan Brotto 420 Reputation points
accepted 2024-10-01T14:47:10.7333333+00:00
Jonathan Brotto 420 Reputation points
0 answers

Like to review records incorrectly entered in the database

We have a database where we enter a record with a number with an alphanumeric suffix. But the software entered it incorrectly due to an algorithm issue which we are trying to fix now but past transactions need to be fixed in the database. If I know the…

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,770 questions
SQL Server Transact-SQL
SQL Server Transact-SQL
SQL Server: A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.Transact-SQL: A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
97 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,637 questions
asked 2024-09-24T16:38:23.5633333+00:00
Jonathan Brotto 420 Reputation points
commented 2024-09-25T21:56:13.35+00:00
Erland Sommarskog 111.1K Reputation points
1 answer

Runing SSAS Tabular Processing Script (TMSL) from SSAS Database Engine

Hello Experts, In continuation of my previous question https://learn.microsoft.com/en-us/answers/questions/2076521/processing-monthly-partition-from-sql-job-using-st?source=docs We have SSAS Tabular model database and SSAS Database engine. When trying to…

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,770 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,282 questions
SQL Server Transact-SQL
SQL Server Transact-SQL
SQL Server: A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.Transact-SQL: A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
97 questions
asked 2024-09-24T11:15:03.1866667+00:00
PANDEY Prashant 125 Reputation points
answered 2024-09-25T02:51:51.62+00:00
MikeyQiaoMSFT-0444 2,950 Reputation points
1 answer

date function in Sql

I have a timestamp where I want to query only based on the date and exclude time.

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,770 questions
SQL Server Transact-SQL
SQL Server Transact-SQL
SQL Server: A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.Transact-SQL: A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
97 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,637 questions
asked 2024-09-24T18:11:46.69+00:00
Jonathan Brotto 420 Reputation points
commented 2024-09-25T01:20:51.7166667+00:00
LiHongMSFT-4306 27,016 Reputation points
3 answers

Way to optimize query where no union needed

I had to use union on two very similar queries where one is just a copy of the other but the having clause is equal with an additional condition in the where clause. Is there a way to clean up the code? DECLARE @PO_DATE_FROM date = '2024-09-08',…

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,770 questions
SQL Server Transact-SQL
SQL Server Transact-SQL
SQL Server: A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.Transact-SQL: A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
97 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,637 questions
asked 2024-09-10T19:56:39.0933333+00:00
Jonathan Brotto 420 Reputation points
commented 2024-09-17T08:53:22.6933333+00:00
Rodger Kong 90 Reputation points
3 answers One of the answers was accepted by the question author.

Queries in the same window for multiple databases, servers, and tables

I was wondering in SSMS in the query window could I write multiple queries that use different servers, databases, and tables? A compounded question and answer I am expecting for this.

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,770 questions
Not Monitored
Not Monitored
Tag not monitored by Microsoft.
39,060 questions
SQL Server Transact-SQL
SQL Server Transact-SQL
SQL Server: A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.Transact-SQL: A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
97 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,637 questions
asked 2024-09-16T13:02:52.5733333+00:00
Jonathan Brotto 420 Reputation points
answered 2024-09-16T21:45:55.07+00:00
Erland Sommarskog 111.1K Reputation points
1 answer

SET FMTONLY ON/OFF is deprecated according to the docs and should be replaced by sp_describe_first_result_set. But sp_describe_first_result_set returns 'incorrect syntax' message on correct queries. How to correctly migrate?

Using this simple table structure: CREATE TABLE Persoon_ ( ID INT, Adres NVARCHAR(50) ) CREATE TABLE Factuur_ ( ID INT, Debiteur INT, Persoon INT, Bedrijf INT, Derde INT ) CREATE TABLE Bedrijf_ ( ID INT, FactuurAdres NVARCHAR(50), …

SQL Server Transact-SQL
SQL Server Transact-SQL
SQL Server: A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.Transact-SQL: A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
97 questions
asked 2024-09-13T08:32:03.4933333+00:00
Carta Online | Hans Wijntjes 0 Reputation points
answered 2024-09-13T22:09:54.04+00:00
Erland Sommarskog 111.1K Reputation points
2 answers One of the answers was accepted by the question author.

Purpose of Schema

What is the purpose of schema? I am a BA like to be more technically knowledgeable.

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,770 questions
SQL Server Transact-SQL
SQL Server Transact-SQL
SQL Server: A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.Transact-SQL: A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
97 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,637 questions
asked 2024-09-11T15:07:16.7566667+00:00
Jonathan Brotto 420 Reputation points
accepted 2024-09-12T13:11:16.5966667+00:00
Jonathan Brotto 420 Reputation points
3 answers One of the answers was accepted by the question author.

How to write/read comma-separated data from an SQL table and load them into a datagridview column?

I want to write comma-separated string values entered in a text box to an SQL table and later fetch them from the table and load them into a data grid view column.

.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,834 questions
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,770 questions
VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,722 questions
SQL Server Transact-SQL
SQL Server Transact-SQL
SQL Server: A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.Transact-SQL: A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
97 questions
asked 2024-09-07T16:06:21.0566667+00:00
Priyantha Niroshan 41 Reputation points
commented 2024-09-10T03:02:23.4266667+00:00
Priyantha Niroshan 41 Reputation points
2 answers One of the answers was accepted by the question author.

Icons in SQL management studio

Like to know what the icons mean SQL management studio. Some are the basics like for the database and some are bit more unique.

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,770 questions
SQL Server Transact-SQL
SQL Server Transact-SQL
SQL Server: A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.Transact-SQL: A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
97 questions
asked 2024-08-30T13:31:40.5733333+00:00
Jonathan Brotto 420 Reputation points
accepted 2024-09-06T13:47:31.77+00:00
Jonathan Brotto 420 Reputation points
1 answer One of the answers was accepted by the question author.

How to extract all email addresses from column XML data - 2008 R2 compatibility mode

Re: How to extract all names from column XML data - 2008 R2 compatibility mode - out of my control There is a column that contains names that are formatted like this - <item xsi:type="bus:custName">willow</item> There can be names.…

SQL Server Transact-SQL
SQL Server Transact-SQL
SQL Server: A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.Transact-SQL: A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
97 questions
asked 2024-08-23T21:22:19.68+00:00
brenda grossnickle 206 Reputation points
commented 2024-08-30T10:49:48.3766667+00:00
Grossnickle, Brenda 60 Reputation points
1 answer

An error in the editor for Ignore Nulls

Hi All, I have a query that retrieve the previous row info for the specific column. The attached image query can be successfully executed. However there is a syntax error line on the editor. The execution engine of the database understand and processes…

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,770 questions
SQL Server Transact-SQL
SQL Server Transact-SQL
SQL Server: A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.Transact-SQL: A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
97 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,637 questions
asked 2024-08-30T07:18:38.8866667+00:00
JAV 0 Reputation points
answered 2024-08-30T08:24:39.8+00:00
LiHongMSFT-4306 27,016 Reputation points
2 answers One of the answers was accepted by the question author.

Join to return default job information if step information is not present

I have a job 1111 with three steps : 11111, 11112, 11113. Steps 11111 and 11112 have a specific delivery method. Step 11113 does not have a specific delivery method so it will use the job default delivery. I have tried to code it my self but the code is…

SQL Server Transact-SQL
SQL Server Transact-SQL
SQL Server: A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.Transact-SQL: A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
97 questions
asked 2024-08-26T20:03:57.4633333+00:00
Grossnickle, Brenda 60 Reputation points
edited an answer 2024-08-29T01:56:34.78+00:00
Rodger Kong 90 Reputation points
2 answers

Database Mail Stopping

Currently having issues on two separate SQL 2022 servers with Database Mail. The service won't auto start up as it should do - I can manually start it and it seems to run for just less than an hour or so and then shuts down and won't restart itself…

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,770 questions
SQL Server Reporting Services
SQL Server Reporting Services
A SQL Server technology that supports the creation, management, and delivery of both traditional, paper-oriented reports and interactive, web-based reports.
2,918 questions
SQL Server Migration Assistant
SQL Server Migration Assistant
A Microsoft tool designed to automate database migration to SQL Server from Access, DB2, MySQL, Oracle, and SAP ASE.
532 questions
SQL Server Transact-SQL
SQL Server Transact-SQL
SQL Server: A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.Transact-SQL: A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
97 questions
asked 2024-08-26T11:16:49.03+00:00
Rabia Kurnaz 386 Reputation points
commented 2024-08-28T05:52:18.7333333+00:00
CathyJi-MSFT 22,201 Reputation points Microsoft Vendor
2 answers

Query to return all users permissions on SQL Server

Hi everyone, Please how can I use TSQL to get the list of all users detailed permissions and privileges on each database. I want the query to return critieria like: Username Database name Login Type (SQL, Windows user or group, etc) Permission Type…

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,770 questions
SQL Server Transact-SQL
SQL Server Transact-SQL
SQL Server: A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.Transact-SQL: A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
97 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,637 questions
asked 2024-08-27T17:35:11.3233333+00:00
tobz 161 Reputation points
answered 2024-08-28T02:50:34.6933333+00:00
LiHongMSFT-4306 27,016 Reputation points
1 answer

Query SQL agent job execution status

Greetings!!! Hi, I have a few jobs that I'm working on sequencing based on dependency. I have a parent job that kick-starts 5 different child jobs. The next step is to make sure all the jobs specified in previous step completed either 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,770 questions
SQL Server Transact-SQL
SQL Server Transact-SQL
SQL Server: A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.Transact-SQL: A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
97 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,637 questions
asked 2024-08-08T22:42:23.0333333+00:00
Raj D 591 Reputation points
answered 2024-08-27T16:24:16.13+00:00
Haris Rashid 81 Reputation points
2 answers

how to return with a nested query two columns from the same table but different results

I have a query where it is a parent query returning results then other results from another table but that table would have two results I would like such as a bill to and ship to where I would like one in each column in the parent query but in the child…

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,770 questions
SQL Server Transact-SQL
SQL Server Transact-SQL
SQL Server: A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.Transact-SQL: A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
97 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,637 questions
asked 2024-08-22T16:12:30.3366667+00:00
Jonathan Brotto 420 Reputation points
commented 2024-08-23T21:38:06.89+00:00
Erland Sommarskog 111.1K Reputation points
1 answer One of the answers was accepted by the question author.

Passing table valued parameter to CLR (C#)

Hi Team, We have a requirement to write a CLR stored procedure which will take multiple no. of rows as input argument, and return same no. of records. Below is the CLR code. public static WebClient client = new…

SQL Server Transact-SQL
SQL Server Transact-SQL
SQL Server: A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.Transact-SQL: A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
97 questions
asked 2024-08-13T10:53:47.2766667+00:00
Shabnam Perween 25 Reputation points
accepted 2024-08-16T08:03:05.8666667+00:00
Shabnam Perween 25 Reputation points
1 answer

Error while updating Always Encrypted column using a stored procedure

In our development environment, one dedicated machine is set as SQL Server Database server. All other development machines are connected to this server as clients using SQL Server Management Studio. Facing some issues after implementing "Always…

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,770 questions
SQL Server Transact-SQL
SQL Server Transact-SQL
SQL Server: A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.Transact-SQL: A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
97 questions
asked 2024-07-26T12:11:53.1966667+00:00
Usha George 0 Reputation points
answered 2024-08-15T10:43:45.31+00:00
Greg Low 1,760 Reputation points Microsoft Regional Director