Tagged Questions
Structured Query Language is a language for interacting with relational databases. Read the tag wiki's guidelines for requesting SQL reviews: 1) Provide context, 2) Include the schema, 3) If asking about performance, include indexes and the output of EXPLAIN SELECT.
1
vote
0answers
6 views
Parsing of XML in Python using minidom, and inserting data into a database
I have some XML that I am parsing in Python and I need to insert the data on the database. This is current implementation of my code that is working.
Actual XML:
...
0
votes
1answer
23 views
-2
votes
1answer
39 views
Adding tables and values to a database
I am having problems with my code because I am using a system called styleci. Can you please check it? How can I make it better and more secure?
...
3
votes
2answers
25 views
Query with many UNION ALL
I'm replicating a scenario on a sample set for better understanding.
Database Table: Products
Report required from that table,
the query is working fine, and I'm able to get the required ...
2
votes
1answer
21 views
Reportable Sp_Who2
One of my issues with sp_who2 is that you need to be in the console to run it as it recalls spid twice and most reporting tools throw this as an error.
My question is, would using the code below to ...
1
vote
0answers
28 views
+50
Shredding XML into an SQL table
I have a few "given" things:
An SQL Server 2012 table with certain structure
Data provided as XML with certain structure
My code has to shred that XML into a ...
7
votes
2answers
129 views
Replacement for sp_MSforeachdb
Having been informed that sp_MSforeachdb is undocumented and unsupported, I have been working on creating a replacement stored procedure based off the work done ...
4
votes
0answers
46 views
Inserting products scraped from the web into a database
I am trying to speed up the runtime of my program as the API can make calls. However after adding the inserts to a database 3 mins turns in 7 mins after 180 API calls, which can be one a second. How ...
5
votes
1answer
50 views
Tools for transferring data from an API to a database
I explain everything on my current code but this question is more general "HOW TO" work correctly with this in this case but even next time.
I have 4 methods in my class, each does something but in ...
1
vote
0answers
25 views
Calculation of duration between two timestamps in different rows
In my sample data table below, all datatypes are varchar(255).
...
1
vote
2answers
62 views
Random uniqueID for each ID SQL
How can I improve this code? I wanted to know if there's a possibility to remove the for loop, and UPDATE a different ...
2
votes
1answer
50 views
Build SQL query criteria from form input
Very new to php. Using XAMPP, netbeans.
I am using a <form> to send various input parameters as a GET to retrieve data from a very simple two table MySQL db.
...
0
votes
0answers
19 views
Stored procedure to compare stored procedure result sets
Originally posted as an answer to a SOF question, this is about a generic procedure that allows back-end developers (e.g. SQL developers) to compare the results sets obtained by running two procedures ...
1
vote
2answers
52 views
Get Word Doc from SQL table, save temp file, edit that file, save new doc in a different table
I have Frankensteined the crap out of this method and just wanted to make sure of two things.
I'd like to make sure that this is the best route to take. If it isn't, I would welcome with open arms ...
1
vote
1answer
49 views
Adding a List to SQL database (Entity Database)
I got a database with members, each member has a list of sports they do.
now I want to loop through a listbox and add every selected item to my database.
This is my database :
And this is my code ...
2
votes
1answer
35 views
SQL Inserting up to 10'000 records from a table to a secondary table
I'm relatively new to ASP.net and working with larger data sets as a fresh graduate, and I am currently maintaining/developing for an ASP webform and T-SQL system at the moment where we have a ...
3
votes
3answers
267 views
SQL Procedure that will calculate the Last Price paid for a certain Part
I am trying to write an SQL Procedure that will calculate the Last Price paid for a certain Part.
...
3
votes
1answer
30 views
Ruby on rails instance loops
I am trying to use a custom sql query to display different attributes for a product i.e. Size and Price. The query I have when running in console displays as it should
...
6
votes
2answers
103 views
Finding customer searches and graphing their items
One of the reports I am working on requires me to locate searches a customer makes, and graph them in certain manners.
I have one query I'm particularly concerned about. This one takes the most ...
0
votes
1answer
31 views
4
votes
1answer
37 views
Highest andLowest in PLSQL
I have made a procedure to display the highest and the lowest popular Items for a particular time of a given date. The procedure works with no errors or exceptions ...
5
votes
1answer
44 views
Report for a restaurant showing hourly sales information for a given timespan
I have been tasked with creating a report for a high-volume restaurant that shows hourly sales information for a given timespan. When generating this report for a single day, it's very quick, but when ...
4
votes
1answer
29 views
Fetching all the project's items for a specific project id
In the following query, I am fetching all the projects items with specific project id. At the same time, I am using a join in Select to fetch the delivered quantity of items of this project only. The ...
6
votes
3answers
324 views
Sum of orders per customer ID
So, I have two tables, customers and orders and I want to get all orders associated with a customer.
The tables look like this:
...
7
votes
2answers
44 views
Execute every Monday that is not the Monday following last Saturday in month
I think the following is good but wondering if it can be simplified or improved.
My condition for code execution is the following:
It is a Monday
AND
It is not the Monday following the last Saturday ...
0
votes
0answers
30 views
django performance - is sql view good enought?
As part of my present project I revived task to deliver group of on-line reports.
As per reports complexity and best performance on my radar I decided to write sql view on Posgres and next attached ...
18
votes
1answer
51 views
Cross-posts from Stack Overflow to CR
What this code does it explained in detail in the top portion of the query.
I have left out part of the list of language tags as I felt it was just noise. You can see the full collection here.
You ...
12
votes
1answer
48 views
Mysql homeowner database
I'm working on a project right now. I don't have much experience in MySQL, or database design, so I was hoping someone could review what I have now.
This database must be able to track multiple home ...
12
votes
2answers
79 views
Query to count interactions between users
The source data represents interaction between people. Some are internal, others are external.
The internals are recorded in the Users table (represented as the ...
8
votes
3answers
127 views
XML splitting query very slow
I have a query to split a delimited string into to multiple columns. The query is extremely slow and takes more than 5 minutes to handle 80444 rows. How can I improve execution time?
...
4
votes
0answers
27 views
Coin flips and Dice rolls in a stored procedure
I saw a post in chat a few days ago, of what I thought was an interesting (albeit fairly simple) statistical challenge:
By @skiwi:
If I shoot once with 50% chance of target A and 50% of target B, ...
4
votes
1answer
512 views
Deleting millions of rows from a MSSQL server table
This SQL query took 38 minutes to delete just 10K of rows. How can I optimize it?
Index already exists for CREATEDATE from ...
5
votes
2answers
72 views
Using UPSERT to maintain word counts for subtitles
I will first explain the context. I want to read serie subtitles contained in .srt files. I have already done the part of extracting the words from the files (and how many times the word appears for a ...
1
vote
0answers
28 views
Inserting non-empty form values into database
I have a form that I submit and returns me about 500 rows.
Before inserting into table I check the strings are not null, this means it loops all the strings.
Is there a better way that it doesnt have ...
4
votes
1answer
28 views
Selecting time metadata off a calendar table
I have a report on SSRS (that's SQL Server Reporting Services) that I need to be able to parameterize so that it can run for..
Yesterday (scheduled every morning)
The week that just elapsed ...
4
votes
0answers
72 views
3
votes
2answers
58 views
4
votes
2answers
64 views
FizzBuzz in T-SQL
I've written a simple FizzBuzz in TSQL using some IF loops.
Here's a SEDE link to run it in your browser.
...
2
votes
2answers
33 views
Sql Server: Getting the highest value based on two uniqueidentifiers - possible to avoid union?
I have two riscProfileTypeIds (both of type uniqueidentifier) of which I need the one with the highest sequence number
(the ...
-4
votes
1answer
37 views
Linq to get records of various status [closed]
I converted an Stored Procedure into a Linq Query, but it do not get any records.
Stored Procedure:
...
3
votes
2answers
60 views
University Database
I am building a database for a hypothetical university. This is my SQL definition, with generated data added for my future use, such as demonstrating queries:
...
1
vote
2answers
89 views
0
votes
2answers
91 views
Select records between the first and last time the speed was positive
I have the following table:
...
13
votes
1answer
94 views
Example script for teaching DDL and CRUD/DML operations
I have taught some SQL to others before, and I thought of making a script that has these attributes, for the purposes of teaching:
Fully functional to run on local DB instance with no fuss
Easy to ...
1
vote
1answer
46 views
Optimise MSSQL Connection .NET Helper Library
I recently posted my old .NET MSSQL Wrapper to be code reviewed: .NET MSSQL Wrapper
I had some good feedback and based on that, I was able to re-factor it quite a bit and ended up with the following ...
1
vote
1answer
31 views
Queries using multiple tables and ANDs: should that be avoided?
This is a part of a project I am working on. I need advice and criticism regarding the data base design and general approach to querying the data. I am not at all experienced with relational data ...
2
votes
2answers
113 views
Save data button
This is a commonly used format for our save button for a lot of our pages. I parameterized (to prevent SQL injection) a lot of this. For this page, there's a ton of textboxes and other stuff, so ...
2
votes
1answer
102 views
Separate model from DB mapper (entity manager)
I've read that it is good to separate model from DB mapper (entity manager) (but at the end, it is perhaps personal - just a matter of opinion). Anyway, if I understood correctly, I should not have ...
1
vote
1answer
40 views
Prices and contracts query
The query below is quite slow (taking about half a second). Any obvious things I could improve?
The PRICES table has about 21 million rows and 30 columns while ...
2
votes
1answer
52 views
T-SQL Constant Time Comparison
Explanation is in the function. Please point out any egregious errors:
...