Click here to Skip to main content
15,892,768 members
Everything / Programming Languages / SQL

SQL

SQL

Great Reads

by Alex Pumpet
A simple program for comparing table data from two sources - SQL databases, Excel, CSV or XML-files
by Thomas Weller
Demonstrates how to run Python scripts from C#
by Mubin M. Shaikh
Create time dimension with 24 hour plus values and time buckets in your data warehouse
by Christoph Buenger
Describes PHP application development with the free Scavix Web Development Framework (Scavix-WDF).

Latest Articles

by Mishael Ogo
A look at a simple SQL builder for Dapper
by GabrieleTronchin
In this project, I've implemented the Transactional Outbox Pattern using EF Core.
by GabrieleTronchin
A simple stored procedure to add at your database to keep it reactive
by GabrieleTronchin
Automatic creation of non clustered indexes using system SQL entities

All Articles

Sort by Updated

SQL 

N 5 May 2024 by Wendelius
As far as I can see, the structure you have thought of should work fine. Each named location is inside another location (street inside a city and so forth). Always when you find a new location you should just add the location to the location tree...
U 5 May 2024 by Wendelius
If update isn't an option, you can always use nested calls to the replace function when selecting, for example select replace( replace( replace('this% contains ! illegal/ chars', '!',''), '%',''), ...
N 4 May 2024 by Pete O'Hanlon
Disclaimer. I love Postgres so my advice is going to centre on you using Postgres. Your third scenario is a prime candidate for using the Geospatial extensions. When you have these installed, you can do queries by location. There are datasets...
N 4 May 2024 by Member 9553610
This is my sample data in a column this is ! Alex23 & and % doing/ *SQL2019 i want this output from above this is Alex23 and doing SQL2019 we are not allowed to use stored procedure and function in organization. so looking for a solution...
N 4 May 2024 by PJ Arends
I am sure I can cobble something together and make this work, but I am seeking some advice from people with experience before I get going on this. First some background. I am trying to organize all our photos in such a way that it is easy to...
N 1 May 2024 by maveň08
You can try: - Collect Data Properly: Instead of directly assigning the Flow to your state variables, collect the data within the LaunchedEffect block and then update the state variables accordingly. - Separate Database Operations: Move the...
U 30 Apr 2024 by PauliKK
The app seems to ignore the database values and defaults to "00-00-0000" for dates and "0" for streak counts, suggesting an issue with the data collection logic or state handling in the composable function.A likely cause could be incorrect data...
N 30 Apr 2024 by Dave Kreskowiak
Since you can connect to the server from outside your network, the SQL Server IS listening to whatever ports are configured, usually 1433. This comes down to some configuration of your network, not the server. You need to describe your network,...
U 30 Apr 2024 by Member 7912784
I have a server with two SQL Server instances on it. I can connect to both of them remotely from any ware in the world however I can't connect to one of them in my local network. I can't find any problem I can connect to both of them out side...
N 30 Apr 2024 by Everything Select
Function in my Dao file is: @Query("SELECT * from appData WHERE type = :type ORDER BY id DESC") fun getData(type: String): Flow> The database contains a column of automatically generated int primary key 'id', a column of...
N 30 Apr 2024 by OriginalGriff
To add to what the others have said, you might want to look at LEAD and LAG - SQL Server | Microsoft Learn[^] Unless this is homework, in which case you only want to use them if the tutor has covered them yet ...
N 30 Apr 2024 by Richard Deeming
Assuming Microsoft SQL Server 2022, something like this should work: WITH cteTimeSlots (SlotStart, SlotEnd) As ( SELECT Convert(time, '00:00'), Convert(time, '00:30') UNION ALL SELECT DateAdd(minute,...
U 30 Apr 2024 by M-Badger
As Pete says, it is difficult to know what you are asking but here's my best guess. You know that the "Before Value" of a row is taken from the "After Value" of the preceding row. Row[N].Before_Value = Row[N-1].After_Value A "group" of rows or...
N 29 Apr 2024 by Pete O'Hanlon
You are missing so much context here that it is impossible for us to come up with a reasoned view of what you are trying to solve. In your example, I have to assume that the space between sections is indicating that these are the groups you need...
U 29 Apr 2024 by asha kumari 2024
1. what is the INITIAL BEFORE VALUE - it should be found in the after values or earlier rows. 2. what is the LATEST AFTER VALUE - it should be found in the before value of subsequent rows 3. In this example there 4 input sets are separate and put...
U 26 Apr 2024 by Dbarton0231
I have a SQL query that provides scheduled activity start and end times grouped by date and employee. The duration of these can span in excess of 30 minutes. I am looking to be able to show duration based on 30 minute intervals. For example,...
20 Apr 2024 by Graeme_Grant
So the issue is the uniqueness of the key. Using a dynamic object is the cause of your issue. Each object is unique. This is easy to demonstrate. Create two instances of a class with the same values, then do a comparison. You will find that they...
20 Apr 2024 by Golden Basim
I need to get the latest purchases cost for every group based on Item , supplier, unit. and synchronization it to another location .. item 1, pack, Jone, ... item 1, pack, Mich, ... item 1, pack, Yasser, ... item 2, pack, Jone, ... item 2,...
20 Apr 2024 by Graeme_Grant
Like desktop apps, you should use multiple techniques to capture and handle errors in your app. Blazor is no different. This page lists a number of strategies that you should be using: Handle errors in ASP.NET Core Blazor apps | Microsoft...
20 Apr 2024 by Prasad Sathe
Data not loading on page refresh in blazor webassembly standalone app What I have tried: I have created a sample web app in blazor as webassembly standalone app, then I simply published this web app in a local folder and hosted it in the iis as...
19 Apr 2024 by Member 16247227
dateadd(day,1,eomonth(dateadd(month,-1,convert(date,getdate()))))
17 Apr 2024 by android androod
Hi I need to display prediction graphs using SSRS to make this accessible to some users who need it. To do this, here are the steps successfully completed using VS community 2019: 1- I created a multidimensional and SSAS analysis project 2- I...
17 Apr 2024 by android androod
I found the solution by modifying the DMX request
16 Apr 2024 by Mishael Ogo
A look at a simple SQL builder for Dapper
16 Apr 2024 by GabrieleTronchin
In this project, I've implemented the Transactional Outbox Pattern using EF Core.
13 Apr 2024 by SproketCoder
I've been attempting to retrieve a table from the SQL DB based on user inputs, but I'm encountering the following error: "Format of the string does not conform to specification starting at index 0". The query I'm using is "SELECT * FROM...
12 Apr 2024 by OriginalGriff
Your command string is wrong: SELECT * FROM @Tablename WHERE Created_On >= '@StartDate' AND Created_On
12 Apr 2024 by raddevus
I also asked this on SO and someone just answered the question over there. I can't believe someone read my entire post and actually gave me the exact solution I was looking for. It's quite instructive. You may want to check it out. ...
12 Apr 2024 by raddevus
Anyone want to take this one on? I promise it's not my homework. 🤓 I'm wondering: 1. how to use only SQL (T-SQL for Microsoft Sql Server) 2. to query 3 tables 3. and insert the result data (shown below) into a new temp table. Temp Table...
11 Apr 2024 by Dave Kreskowiak
If you're using a 32-bit tool, you have to use the 32-bit ACE driver. You cannot mix 32-bit and 64-bit code in the same process.
11 Apr 2024 by Member 13694735
I am using SSMS to import an Excel spreadsheet to a SQL table. After typing in the Excel info, I get 'Microsoft.ACE.OLEDB.12.0 provider is not registered on the local machine' error. What I have tried: I have download the following...
8 Apr 2024 by Richard Deeming
Something like this should work: UPDATE U SET First_Name = P.firstName, Last_Name = P.lastName FROM dbo.[USER] As U CROSS APPLY dbo.Name_Parser(U.Full_Name) As P ; However, you should probably read Falsehoods Programmers...
7 Apr 2024 by markmoss
Hello, I have a UDF([Name_Parser]) that accepts a name ('Mrs. Thurston Howell, IV' and returns the following original: Mrs. Thurston Howell, IV prefix: Mrs firstName: Thurston middleName: ...
30 Mar 2024 by GabrieleTronchin
A simple stored procedure to add at your database to keep it reactive
30 Mar 2024 by GabrieleTronchin
Automatic creation of non clustered indexes using system SQL entities
26 Mar 2024 by PeterA
Hi, I am trying to return a list of Reports from our SSRS Reporting server using C# and Visual Studio 2022. I have seen many examples on the internet on how to achieve this but non of then work (they are all basically the same). I have even...
25 Mar 2024 by Darshan Vyas 2022
This code should give you the desired output format. Now, you can use this value variable to display your data in a Tkinter GUI, such as with a CTKtable widget. You'll need to integrate it into your Tkinter application accordingly. from...
25 Mar 2024 by Member 15783420
I need to build a Tkinter desktop app with Sqlalchemy as a database. If I read the SQLite database, and print both the header and content of database as show as below: What I have tried: from sqlalchemy import text,...
24 Mar 2024 by Pete O'Hanlon
If I were you, I'd start off by investigating what you can do with Large Language Models (LLMs). You should try out something like Ollama[^], which let's you download and try different models. This is a great way to dip your toes into the ML waters.
23 Mar 2024 by Max Speed 2022
Hello experts I want to use your experience, I want to enter artificial intelligence from software engineering, I have worked in the field of software with c# language for desktop programming and mvc for web programming and I have also worked...
22 Mar 2024 by raddevus
An informal study of the Sqlite database and how many concurrent inserts it can handle. Will help you decide if you want to use Sqlite in your projects.
12 Mar 2024 by carlitosd19
OK, I find a way to fix this: 1-Set you connection string inside the Data Source in the General Tab (include your username and password) 2-On the Credentials Tab, set "Do not use credentials" 3-Save the report and reopen and run it. that's all :)
12 Mar 2024 by OriginalGriff
If I try your values I get what I expect:SELECT (487-556)/556 Gives me 0 as it is integer arithmetic.SELECT (487.0-556.0)/556.0 Gives me -0.1241 because it's floating point arithmetic. Check your data sources and make sure the types are what you...
12 Mar 2024 by TLeisusmc
I am building a report and I put in the standard equation of (487-556)/556. The answer should be -.12. However, the result shows -334. How? I cannot think of any sequence that would equal -334. When I change it to (487-556/556) or 487-556/556 it...
12 Mar 2024 by OriginalGriff
Because your math is wrong! :D DECLARE @cnt INT = 6785; WHILE @cnt 0 THEN CHAR(65 + ((@cnt - 27) / (26 * 26))) ELSE '' END , Char(65 + (@cnt...
12 Mar 2024 by CHill60
Having a dense/senior moment today... I have an (inherited) SQL query running against a cte that now produces rows numbered from 1 to 16384. I'm expecting it to generate column letters in the range "A" to "XFC" (Previously generated "A" to "ZZ")...
11 Mar 2024 by Andre Oosthuizen
In SQL, single quotes should be used for string values, not backticks. Also, there's a missing space before the 'SET' in your query which reads as - "UPDATE clinic_inventorySET. Your sql should look like - $sql = "UPDATE clinic_inventory SET "...
11 Mar 2024 by Raiden Peñaverde
Hello! I'm making a simple table for a school project and I've found this tutorial helpful "https://www.youtube.com/watch?v=NqP0-UkIQS4"> PHP and MySQL with CRUD Operations: Create, Read, Update, Delete - YouTube I followed everything but when it...
27 Feb 2024 by zjkal
I feel it may be because your data table name contains spaces, because I have never used it like this before.
26 Feb 2024 by OriginalGriff
To add to what the others have said, you need to be more careful with your conditions:IF LEN(@Mobile) =10 ) Will always be true as one side or the other of the OR will always be true.
26 Feb 2024 by _Asif_
Your SP has syntax errors and should not compile. I have made a couple of changes in your SP to get it in a working condition but you need to understand that your SP has logical errors. ALTER PROCEDURE [dbo].[SendSMS_TestMark] @EntityID INT...
26 Feb 2024 by Dave Kreskowiak
I don't see an END CATCH anywhere, so that's going to be a problem. Also, you're not throwing an exception anywhere for the TRY block to catch. Just failing an IF statement does not throw an exception. Frankly, I don't see anything here that...
26 Feb 2024 by Mark Smith 2024
ALTER PROCEDURE [dbo].[SendSMS_TestMark] @EntityID INT , --PolicyID @Mobile VARCHAR(11) , @Message VARCHAR(480) ,--What Needs to be send Text @ScheduleDateTime DATETIME , --Same date sync @DateCreated DATETIME, --Same date sync ...
25 Feb 2024 by SulfySul
I have been working on Flutter development using SQL Database + ASP.NET REST API for the backend. However, I'm now considering transitioning to either Firebase or Appwrite due to their increasing popularity and ease of implementation. As I plan...
23 Feb 2024 by Mohammad Elsheimy
One of the major issues encountered when connecting to databases after porting ASP.NET app to Docker Linux containers.
22 Feb 2024 by Chris_List
Hello- I am trying to get a list of orders that came across each server by the minute. I am able to get that with a simple script but I have to change the WHERE clause for each minute. I'm hoping to find something that can query the range in one...
21 Feb 2024 by Richard Deeming
Start by counting the orders for each server for each minute: DECLARE @day datetime = '2024-02-21'; SELECT c.line As SERVER, M.Minute, COUNT(DISTINCT c.id) As OrderCount FROM customer c INNER JOIN orders o ON o.id = c.id ...
20 Feb 2024 by Maciej Los
I'm no sure what you want to achieve... I believe below example will help you to understand how to filter your data. DECLARE @cn AS INT = 253; -- 253 --594 --2132 DECLARE @ip AS INT = 1; DECLARE @pcn AS INT = 0; WITH cte AS ( SELECT...
20 Feb 2024 by Jalapeno Bob
If I remember my SQL, the parameter types must all be string, not integer. Try that.
20 Feb 2024 by Pop Tufty
Well, I guess that I need more coffee. It turned out that PermitID was a string, but was set to "foo" - duh - no wonder - thanks for looking once I set it to "42" it worked. I don't feel too
20 Feb 2024 by Pop Tufty
In SQL server, I created this sproc: CREATE PROCEDURE [dbo].[GetOutletInfo] @PermitID int AS SELECT * FROM Outlets WHERE PermitID=@PermitID GO then in my C# code, I run this: var cn = new SqlConnection(connectionString); SqlDataAdapter da;...
19 Feb 2024 by Red Kipling
I have to insert a table in my databasse and the table name is pbb_prefix and he contains 3 columns: id,prefix,forum when i run this command $info_query = $PowerBB->DB->sql_query("SELECT * FROM " . $PowerBB->table['info'] . " WHERE...
19 Feb 2024 by DT_2
I need to find the immediate parent id based on the below condition: |CustomerNum|ParentCustomerNum|IsPlatform| |-----------|-----------------|----------| |132 |0 |1 | |253 |132 |0 |...
17 Feb 2024 by Higty
A DAL generator that generates StoredProcedure client class and creates Table and Record classes
16 Feb 2024 by Andre Oosthuizen
In addition to what OriginalGriff suggested, you can automate this rather than changing your code all of the time to ensure a successful connection - You need to dynamically adjust your connection settings based on the specific database version...
15 Feb 2024 by OriginalGriff
SQL databases are tagged with a version number: the version that wrote the database file. When your code connects to the DB via the SQL Server engine, it checks the engine version against the file version - if the DB shows a later version than...
15 Feb 2024 by yossef2023
Hello everyone, why does this message appear? microsoft visual studio an incompatible sql server version was detected. What I have tried: SSDT installed did not solve the problem Thank you all
14 Feb 2024 by M Imran Ansari
Check the refer article and try to use "(localdb)\mssqllocaldb" as the server name for connecting to the LocalDB instance, for example: SQLCoffee - Breaking Changes to LocalDB[^]
14 Feb 2024 by OriginalGriff
Quote: Online. Is there a link to how to solve the problem? Read the message carefully: it says that it either can't find SQL server at the address given in your connection string, or the server is hosted on a different computer which is not...
14 Feb 2024 by yossef2023
Hello, what is the reason for this message? a network-related or instance-specific error occurred while establishing a connection to sql server. the server was not found or was not accessible. verify that the instance name is correct and that...
13 Feb 2024 by OriginalGriff
Add an SQL WHERE Clause[^] Provided you have stored your dates in DATE, DATETIME, or DATETIME2 in your DB, SQL can cope with date comparisons just as it can cope with numeric ones. You may also find the SQL Server DATEADD() Function[^] useful in...
13 Feb 2024 by Member 12200213
select date from Ordersdate not to display current date and next day date remaining dates needs to display. Thanks Vinoth What I have tried: select date from Ordersdate not to display current date and next day date remaining dates needs...
12 Feb 2024 by George Swan
It seems to me that your problem here is in this line of code: TypeofRest = g.Select(x => x.TypeofRest), Result = g.Select(x => x.Result) }) The Select method returns an IEnumerable so both TypeofRest and Result are both IEnumerables. The...
11 Feb 2024 by Max Speed 2022
Hello experts I have a query and everything in my query works well without the last condition, I use the last condition to filter the joined tables, but I get this error: Operator == cannot be applied to operands of type IEnumerable and...
11 Feb 2024 by Maciej Los
Please, read this: Compiler Error CS0019 - C# | Microsoft Learn[^]
7 Feb 2024 by Pete O'Hanlon
If the code doesn't appear to be following the correct code flow after calling the stored procedure, it could well be that you have encountered an exception that is interrupting the flow. To test this, wrap the call to the stored procedure in a...
7 Feb 2024 by whistle1973
I have a stored procedure that runs correctly from SQL. However, when I call the procedure from VB.Net it completes all the process but doesn't release and move on the the next line of code. I am calling the procedure like I all the others I...
29 Jan 2024 by Mayank Kushwaha 2022
public partial class ControlCenter : System.Web.UI.Page { GetData GetConn = new GetData(); //protected PlaceHolder cardContainer; protected Panel cardContainer; protected void Page_Load(object sender, EventArgs...
25 Jan 2024 by CHill60
Your problem is that you have nothing that links the items together. Just because you enter the data in that particular order, does not mean that SQL will return it in that order when you do a select * You need an addtional column that helps you...
24 Jan 2024 by bjane
How to remove null values and display non-null values in multiple rows col1 col2 col3 ann null null null dev null null null ora null null own add null null null dig null output col1 col2 col3 ann dev ora add dig own What I have tried: ...
22 Jan 2024 by M Imran Ansari
To generate the matrix with predefined user roles, you can use the below SQL query through SELECT statements and conditional logic. The MAX function is used to consolidate the information for each role within the GROUP BY clause. In this context,...
21 Jan 2024 by Manjuke Fernando
Hi, Anyhow you can use PIVOT and achieve this. If the ROLE_ID's are limited, you can use a static values in your query. But if it's not limited, then you may required to generate your PIVOT query dynamically, and execute it. Btw, your results...
21 Jan 2024 by chamindat
USER TABLE ========== USER_ID USER_NAME 1150080 XXXXXXXXXXXX 1150081 YYYYYYYYYYYY 1150082 ZZZZZZZZZZZZ 1150083 RRRRRRRRRRRR 1150084 WWWWWWWWWWWW 1150085 TTTTTTTTTTTT 1150086 EEEEEEEEEEEE 1150087 ...
19 Jan 2024 by bmw318mt
Yes I am sure database could be reached. Out of 3000 tests some are failing randomly with Sql timeouts. Below is the method I am using to open the DB connection private DbConnection GetDBConnection() { var db =...
19 Jan 2024 by bmw318mt
I have tests executing that are using an SQL database hosted on Docker. I am facing timeout issues on some tests var msSqlContainer = new ContainerBuilder() .WithImage("mcr.microsoft.com/mssql/server:2017-latest")...
17 Jan 2024 by theskiguy
I figured it out. It was a stupid typo. On the 4th line from the bottom I had "as TF", should have just been just "TF"
17 Jan 2024 by theskiguy
I am try to update an existing query to include 2 subqueries each computing a different count. The main query runs fine on its own and I have been able to get the 2 subqueries to run on their own, however, when I try to join them, I am getting a...
11 Jan 2024 by Nicolas DESCARTES
How to write a lexical analyzer for SQL?
9 Jan 2024 by Member 14760154
I have a query like this var db, err = sql.Open("mssql", connString) if err != nil { log.Println("Open connection failed:", err) } err = db.Ping() if err != nil { log.Println("Cannot connect: ", err) } defer db.Close() if err != nil...
7 Jan 2024 by yuvalsol
POCO generating application for SQL Server
6 Jan 2024 by Maciej Los
Well, BETWEEN operator is used without any "key". See: SQL BETWEEN Operator[^]
6 Jan 2024 by OriginalGriff
While we are more than willing to help those that are stuck, that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for...
6 Jan 2024 by Vinay Hosamath
Inbetween condition which key or operator we use...??? What I have tried: In between condition which operator we use...??
29 Dec 2023 by CHill60
Use dymamic sql queries - examples here Execute Dynamic SQL commands in SQL Server[^] or here - SQL Server Dynamic SQL[^] Edit: Apologies for not reading your question properlyQuote: I want to take every nth row to get a series of rough data. ...
29 Dec 2023 by M Imran Ansari
Here is a comprehensive guide with multiple options for SQL Query with a Dynamic LIMIT: https://copyprogramming.com/howto/how-to-write-a-sql-query-with-dynamic-limit[^]
28 Dec 2023 by kenny_-_
Hello all, I'm bending my head over something that might have an obvious solution Im missing. I have a big database in mssql and i'm using Grafana. For retrieving a big piece of history I'd like to dynamically limit the returned results in my...