Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Posts tagged sql

12 child tags

Use for questions about one or multiple Structured Query Language (SQL) flavours.

In order to get the most helpful answer your question should include the following:

- a specific SQL flavor tag (e.g. for MySQL, PostgreSQL, Oracle, MS SQL Server, IBM DB2)
- table definitions
- sample data if needed
- expected result when query results are not what you expect

For general questions that are not targeting a specific SQL flavor, questions and answers should use ISO/IEC standard SQL.

This tag doesn't have a detailed wiki yet.

42%
+1 −2
Q&A Why OFFSET isn't working the way it is expected?

I had three data with where gender=female. I was trying to call those data with limit and offset (Since in future there might be more than 1000 data). SELECT * FROM `users` WHERE `gender`='Female'...

1 answer  ·  posted 5mo ago by billy‭  ·  edited 5mo ago by Alexei‭

Question mysql sql
60%
+1 −0
Q&A VBScript Listener in SSRS

Is it possible to add listeners via VBScript/ JS directly into a SRSS report? Goal: Track changes of input fields and key press inside the wrapper React based on the events Directly in the...

0 answers  ·  posted 9mo ago by Yolanda‭  ·  edited 9mo ago by Alexei‭

50%
+0 −0
Q&A How to get rid of HTML tags and convert entities in SQL Server?

I have to migrate a bunch of text from an old application into a new one. Some of these texts contain HTML tags and entities (HTML editor was used) and now they do not want to support this in the n...

2 answers  ·  posted 1y ago by Alexei‭  ·  last activity 12mo ago by gbjbaanb‭

Question html sql-server
71%
+3 −0
Q&A Conditions which always matches returns no result with CTE

I have the following scenario (in MySQL 8): CREATE TABLE `steps` ( `id` int NOT NULL AUTO_INCREMENT, `number` varchar(30) DEFAULT NULL, `parent_number` varchar(30) DEFAULT NULL, `timestamp` ti...

1 answer  ·  posted 1y ago by artaxerxe‭  ·  edited 1y ago by Alexei‭

77%
+5 −0
Q&A Is an ORDER BY required when looping through MySQL records with LIMIT?

Let's say I have a table with 10,000 rows and instead of selecting all of the rows at once I select 1,000 at a time like LIMIT 0,1000 LIMIT 1000,1000 etc. Without an ORDER BY statement the or...

1 answer  ·  posted 2y ago by Charlie Brumbaugh‭  ·  edited 1y ago by Alexei‭

66%
+2 −0
Q&A Rationale of using database-level transactions inside a store procedure when application layer already manages a transaction

One of the legacy applications my team has to maintain has almost always this pattern for dealing with data modification: try { // get the connection // begin transaction // optional...

0 answers  ·  posted 1y ago by Alexei‭  ·  edited 1y ago by Canina‭

80%
+6 −0
Q&A When stored procedures are preferred over application layer code?

A person I used to work with several years ago was hired to rewrite a product using a .NET-based modern tech stack. One of the aspects that stroke me was that he believes that the product should mo...

2 answers  ·  posted 1y ago by Alexei‭  ·  last activity 1y ago by Derek Elkins‭

71%
+3 −0
Q&A Transferring files from a legacy project to an existing one as varbinary

Our team is currently transferring all functionality (+ some changes) from small and very old project A (almost code freeze) to project B (actively developed). As part of the data migration, there ...

1 answer  ·  posted 1y ago by Alexei‭  ·  last activity 1y ago by Derek Elkins‭

50%
+0 −0
Q&A How to to make a store tree view cart

I am building an MVC cart system. I have the MERCHANTS table and the PRODUCTS table. A merchant (store) can have one or more products, everything works fine but what I want is to display products b...

0 answers  ·  posted 1y ago by Fyoni‭  ·  edited 1y ago by Alexei‭

Question php mysql pdo treeview
75%
+4 −0
Q&A What are the disadvantages of using SQL Server Replication - Transactional Replication type?

The context A reports related process is directly reading the production operational database once about two hours. This involves reading all the data from some 70 tables which takes a couple minu...

0 answers  ·  posted 1y ago by Alexei‭

71%
+3 −0
Q&A Is there any justification for having a single tempdb database to be used by all databases on a SQL Server intstances?

Despite the fact that I have programmed against SQL Server for quite a while I did not pay much attention to the tempdb database. This is especially true if application logic is mostly written usin...

1 answer  ·  posted 1y ago by Alexei‭  ·  last activity 1y ago by Derek Elkins‭

33%
+0 −2
Q&A Why comma is expected for auto_increment?

query = "CREATE TABLE "+TABLE+" ("+COLUMN1+" INTEGER PRIMARY KEY NOT NULL AUTO_INCREMENT, "+COLUMN2+" VARCHAR(255), " + COLUMN3+" VARCHAR(255), "+COLUMN4+" TEXT, "+ COLUMN5+" VARCHAR(255)...

1 answer  ·  posted 1y ago by Anonymous‭  ·  edited 1y ago by Alexei‭

66%
+2 −0
Q&A What's the better way to store base64 in SQLite Database?

What's the better way to store base64 in SQLite Database? I was thinking to put base64 as TEXT since base64 has lots of chars. CREATE TABLE name (id INTEGER PRIMARY KEY AUTO_INCREMENT, image TEXT)...

1 answer  ·  posted 1y ago by Anonymous‭  ·  edited 1y ago by Anonymous‭

Question sql base64 sqlite
71%
+3 −0
Q&A How to create a MySQL generated column that uses a join in a concat?

I have a column that is a concatenation of 5 other columns plus a join to a different table. UPDATE db.a JOIN db.b ON fk_b = b.pk SET concat_field = CONCAT(field1,field2,field3,b.field,field4,fi...

1 answer  ·  posted 2y ago by Charlie Brumbaugh‭  ·  last activity 2y ago by Alexei‭

66%
+2 −0
Q&A How to start mysql in Manjaro from terminal?

I had installed mysql using the following command sudo pacman -Sy mysql Earlier, I was using Lampp(Xampp for Linux) where I could start using the command /opt/lampp/start start I am not sur...

1 answer  ·  posted 2y ago by deleted user  ·  last activity 2y ago by deleted user

60%
+1 −0
Q&A Is there any breaking change in regard to TrustServerCertificate property of System.Data.SqlClient for .NET 5?

I have recently an issue at work after upgrading an ASP.NET Core 3.1 application to .NET 5. It worked correctly on all environments (e.g. PreProd, Prod) when targeting 3.1, but failed on Prod only ...

1 answer  ·  posted 2y ago by Alexei‭  ·  last activity 2y ago by Alexei‭

50%
+0 −0
Q&A When is information schema not needed and when is it indeed when migrating from one website hosting provider to another?

In some situations, could it be problematic to migrate a website's database (MySQL) from one website hosting provider to another without the information schema or with the information schema? In m...

0 answers  ·  posted 2y ago by deleted user  ·  edited 2y ago by deleted user

Question mysql database
66%
+2 −0
Q&A How to easily support time frame grouping in queries?

I had a curiosity about how much the experienced users wait for their questions to be answered on Stack Overflow and had written a query for it: SELECT YEAR(q.CreationDate) * 100 + MONTH(q.Creatio...

0 answers  ·  posted 2y ago by Alexei‭  ·  edited 2y ago by Alexei‭

75%
+4 −0
Q&A How to break infinite loop in CTE

I have a parent child relation in my table, with possibly circular cases. Is it possible to break the infinite recursivity in CTE checking values of all previous rows? I would need something like t...

3 answers  ·  posted 2y ago by artaxerxe‭  ·  last activity 2y ago by Peter Taylor‭

81%
+7 −0
Q&A SQL timestamp for daylight saving day when clock goes 1 hour back.

On 25th October 2020 in Europe/Berlin clocks where set back from 03:00 AM to 02:00 AM to change from summer time (CEDT) to winter time (CET). Which means there is a 1 hour separation between 02:30...

1 answer  ·  posted 2y ago by Estela‭  ·  last activity 2y ago by hkotsubo‭

66%
+2 −0
Q&A Is it possible to disable the "mysql: [Warning] Using a password on the command line interface can be insecure" warning?

For my purposes, it is secure enough to use passwords to execute MySQL commands on the command line, what I would like to do is disable the warning that says, mysql: [Warning] Using a password on ...

1 answer  ·  posted 2y ago by Charlie Brumbaugh‭  ·  last activity 2y ago by Alexei‭

Question mysql
71%
+3 −0
Q&A What are the factors to consider when deciding to split ORM queries or use eager loading?

I have extensive working experience with Entity Framework ORM and have noticed two major ways of writing LINQ (LINQ2SQL): lot of eager loading: the most prevalent, uses (lots) of Includes to eag...

0 answers  ·  posted 2y ago by Alexei‭

75%
+10 −2
Q&A What are the pros and cons of a composite primary key versus a unique constraint?

Let's say we have two tables A and B and a join table C that has foreign keys to both A and B and the combination of those foreign keys is unique. One could either do a unique constraint or a comp...

2 answers  ·  posted 2y ago by Charlie Brumbaugh‭  ·  edited 2y ago by Alexei‭

77%
+5 −0
Q&A Is it unsecure to use a password on the command line to run a MySQL script on Windows?

Its possible to execute a MySQL file from the command line like so, mysql -u USER -pPASSWORD &lt; FILENAME which triggers a warning, mysql: [Warning] Using a password on the command line int...

2 answers  ·  posted 2y ago by Charlie Brumbaugh‭  ·  edited 2y ago by ghost-in-the-zsh‭

Question mysql windows
66%
+2 −0
Q&A How much memory is allocated for a MySQL VARCHAR variable in a stored procedure?

In a stored procedure let's say I have a VARCHAR variable, DECLARE example_variable VARCHAR(100); how much memory is allocated to it and is that independent of the length of the data in the var...

2 answers  ·  posted 2y ago by Charlie Brumbaugh‭  ·  last activity 2y ago by Alexei‭

86%
+11 −0
Q&A Are there best practices for sticking conditions in WHERE clauses vs the JOIN statement?

Lets say I have two tables, A and B and I need to join a subset of them. Is there best practices of sticking the conditions in the WHERE clause like this, SELECT * FROM A JOIN B on a.fk_b = b....

2 answers  ·  posted 2y ago by Charlie Brumbaugh‭  ·  last activity 2y ago by klutt‭

Question mysql join
75%
+4 −0
Q&A Is there a way to automatically fix MySQL tables where the auto_increment has fallen behind the correct value?

Due to a series of unfortunate events I have some tables where the auto_increment value got behind what it should be. If the auto_increment value is 9 and there are 20 rows in the table the next 1...

1 answer  ·  posted 2y ago by Charlie Brumbaugh‭  ·  last activity 2y ago by Alexei‭

71%
+3 −0
Q&A In MySQL is there a limit to the number of keys in a IN() clause?

I have a PHP program that does a SELECT and then updates some of the values based on an algorithm. Rather than updating one row at a time UPDATE example_table SET COLUMN_A = 1 WHERE primary_k...

2 answers  ·  posted 2y ago by Charlie Brumbaugh‭  ·  last activity 2y ago by Alexei‭

Question mysql
71%
+3 −0
Q&A Iterating through a MySQL table with a LIMIT clause and PHP gets progressively slower

I have a very large table that I need to iterate through with a PHP script and I can't do all of the results at once so I do it in sections with a LIMIT like for ($x = 0; $x &lt; 10000000; $x += 1...

1 answer  ·  posted 2y ago by Charlie Brumbaugh‭  ·  last activity 2y ago by ArtOfCode‭

Question php mysql
71%
+3 −0
Q&A Why would an unique index get moved to the primary key after the underlying column is dropped?

So I had a table with a primary key and a bunch of different columns. Columns A, B, and C were all unsigned ints (like the primary key column) and each column had a unique constraint I dropped the...

1 answer  ·  posted 2y ago by Charlie Brumbaugh‭  ·  edited 2y ago by Alexei‭

77%
+5 −0
Q&A Is it possible in MySQL to require each row in a table have at least one foreign key record in a join table?

I have tables A and B and then I have a many to many join table with foreign keys to both called a_b. Neither foreign key can be null and the combinations for the foreign keys to A and B are unique...

2 answers  ·  posted 2y ago by Charlie Brumbaugh‭  ·  last activity 2y ago by Alexei‭

Question mysql referential
50%
+0 −0
Q&A How to drop all stored procedures from a MySQL database

I need to drop all of the stored procedures from my MySQL database before I recreate them. How can I do so?

1 answer  ·  posted 2y ago by Charlie Brumbaugh‭  ·  edited 2y ago by Peter Mortensen‭

71%
+3 −0
Q&A SID to login for access via a group

I have a query that returns the owner of jobs on an SQL instance, select s.name as JobName , s.owner_sid , ISNULL(L.name,'AccessViaGroup') as LoginName --Trying to figure out how to turn that ...

0 answers  ·  posted 2y ago by James Jenkins‭  ·  edited 2y ago by Alexei‭

60%
+1 −0
Q&A How can I can I reduce the size of a SQL Server database after being restored and massive embedded files stripped?

My project has the following set up for the production and preproduction ("clone") environment. Production is not accessible at all for the development team, only the preproduction database. Pr...

1 answer  ·  posted 2y ago by Alexei‭  ·  last activity 2y ago by Alexei‭

71%
+3 −0
Q&A How do I track down intermittent locks in a MySQL database?

Currently, we have a CRUD plus reporting application that talks to one MySQL database. Intermittently users will report locks when searching, currently, I can only get the approximate time of when ...

0 answers  ·  posted 2y ago by Charlie Brumbaugh‭  ·  edited 2y ago by Alexei‭

66%
+2 −0
Q&A In MySQL, is it possible to disable triggers for only certain queries or users?

Almost every table in my DB has triggers that fire on INSERT, UPDATE, DELETE and write the changes to a separate read only DB. This makes it possible to track changes and undo things well after the...

1 answer  ·  posted 2y ago by Charlie Brumbaugh‭  ·  edited 2y ago by Alexei‭

80%
+6 −0
Q&A How are integers interpreted in contexts that expect a date?

I found a confusing construction in several stored procs in an MS SQL 2008 R2 database: DATEADD(dd, 0, DATEDIFF(dd, 0, some_date)) As I understand it, these are the relevant function signatures: D...

1 answer  ·  posted 2y ago by ajv‭  ·  edited 2y ago by Alexei‭

Question sql tsql sql-server
71%
+3 −0
Q&A How to calculate how much data is stored in a MySQL column?

I am considering either removing some columns or changing the datatypes if I could significantly reduce the amount of storage that is currently used by those columns. Some of the columns are ints a...

1 answer  ·  posted 2y ago by Charlie Brumbaugh‭  ·  last activity 2y ago by Alexei‭

Question mysql
75%
+4 −0
Q&A Would a MySQL database run more efficiently with smaller varchar lengths?

I have a database with quite a few VARCHAR fields. When the database was first built the lengths of the columns were set a bit larger than absolutely necessary. Now after, having used the DB for a ...

3 answers  ·  posted 2y ago by Charlie Brumbaugh‭  ·  last activity 2y ago by manassehkatz‭

71%
+3 −0
Q&A Error: 18456, Severity: 14, State: 5; SSMS > Network sever from PC

I just completed my first install of SQL as a server-based, Enterprise Edition. I wanted to check it out using SSMS on PC using my Admin Access. But could not connect. For security reasons my adm...

1 answer  ·  posted 2y ago by James Jenkins‭  ·  edited 2y ago by Alexei‭

77%
+5 −0
Q&A Is there a naming convention for table aliases?

Sometimes, either to reduce the amount of typing big table names or when joining a table to itself one will need to alias a table. Personally I find SQL statements with aliases harder to read and a...

1 answer  ·  posted 2y ago by Charlie Brumbaugh‭  ·  edited 2y ago by Alexei‭

75%
+4 −0
Q&A How can I generate documentation from comments in SQL DDL?

I have some SQL scripts that contain DDL to create tables and schemas for a database. I'd like to be able to comment this SQL and then use those comments to generate output documentation (in HTML)...

0 answers  ·  posted 2y ago by Monica Cellio‭  ·  edited 2y ago by Monica Cellio‭

81%
+11 −1
Q&A Why would excluding records by creating a temporary table of their primary keys be faster than simply excluding by value?

I have two tables with millions of records. Every so often I need to join them and exclude just a handful of records where a bit(1) column is set to 1 instead of 0. I can do it with either, WHERE ...

2 answers  ·  posted 2y ago by Charlie Brumbaugh‭  ·  edited 2y ago by Alexei‭

60%
+1 −0
Q&A What is the rationale of having Cascade as a DeleteAction in EntityFramework.Core?

I have noticed some time ago that Entity Framework assumes a CASCADE behaviour (implicit value, if not specified) for referential constraints (FKs) when deleting items. This means that by default, ...

1 answer  ·  posted 2y ago by Alexei‭  ·  last activity 2y ago by Alexei‭

75%
+4 −0
Q&A Is there an equivalent way of returning early in a MySQL stored procedure?

In programming instead of arrowcode where one has many layers of indented if statements, you can return a result as soon as possible. So instead of, if if end if end if It looks like if ret...

1 answer  ·  posted 2y ago by Charlie Brumbaugh‭  ·  edited 2y ago by Moshi‭

60%
+1 −0
Q&A What is happening under the hood to the selected data in a MySQL cursor?

I have a number of MySQL stored procedures that use a cursor to go through a select and then pass the results to other stored procedures one row at a time. This can take a while to run, what is hap...

0 answers  ·  posted 2y ago by Charlie Brumbaugh‭  ·  edited 2y ago by Charlie Brumbaugh‭

Question mysql
83%
+8 −0
Q&A Is there a way to estimate the execution time of a statement in MySQL?

From time to time I will have large structural changes to make on my MySQL DB, things like adding columns, changing datatypes, adding indexes etc. These types of changes result in downtime and what...

1 answer  ·  posted 2y ago by Charlie Brumbaugh‭  ·  last activity 2y ago by meriton‭

Question mysql
60%
+1 −0
Q&A In a stored procedure, is it possible to get the total number or rows updated by different statements?

I have a bunch of stored procedures that look like something this CREATE PROCEDURE example() BEGIN UPDATE STATEMENT A; UPDATE STATEMENT B; UPDATE STATEMENT C; END// When I run them thr...

2 answers  ·  posted 2y ago by Charlie Brumbaugh‭  ·  last activity 2y ago by Alexei‭

71%
+3 −0
Q&A How long in days is a MONTH in MySQL?

If one finds where the past number of months equals the past number of days like this, select distinct DATE_SUB(now(), INTERVAL 92 DAY),DATE_SUB(now(), INTERVAL 3 MONTH) The numbers that are curre...

1 answer  ·  posted 2y ago by Charlie Brumbaugh‭  ·  last activity 2y ago by r~~‭

Question mysql
33%
+0 −2
Q&A How do I find all the tables in a database that don't have a specific column?

I need to add one column with the same name to all of the tables in my database, how can I find which tables don't currently have a column with that name?

1 answer  ·  posted 2y ago by Charlie Brumbaugh‭  ·  last activity 2y ago by Charlie Brumbaugh‭

Question mysql