Questions tagged [variable]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
1 answer
13 views

execute insert and select statements consecutively after a case statement

I want to execute insert and select statements once a condition is met on mysql, not sure how to do it. ##declare variables SET @fvar = 'sometxt', @svar = 'sometxtagain'; SELECT @start := 1, @...
0 votes
0 answers
23 views

How to use variable in the select query PostgreSQL

I'm looking for a way to write a recursive query, but I'm getting an error. "SQL Error [42601]: ERROR: syntax error at or near "with recursive" Position: 287" query result "...
0 votes
1 answer
42 views

Average Density & cardinality estimation

In a large web application we had a query that was running slow in code, that seemed to be working blazing fast in SSMS. After checking the basics like the same SET options, we found that there was ...
0 votes
0 answers
21 views

Local variables and their impact on execution plans in SQL Server Stored Procedure [duplicate]

If a parameter that is passed to stored procedure is assigned to a local variable and the local variable is used inside the stored procedure logic, will that affect the execution plan in any way? Is ...
0 votes
0 answers
101 views

MySQL IF NULL of a variable is not working as expected in a trigger

We have the following trigger to ensure that a version field is updated in a related table, normally the trigger contains only the UPDATE statement, the INSERTs are added for debugging and to explain ...
1 vote
1 answer
212 views

Is it safe to use user defined variables inside stored procedures in MySQL?

Currently I'm working with Stored Procedures in MySQL and I'm using in some procedures user-defined variables and I've seen that type of variables are initialized in the current session and keep their ...
0 votes
1 answer
137 views

Count how many variables equal a target value

Is there a smart way to count how many variables equal some target value (in SQL Server)? For example, if I have: declare @a int = 1; declare @b int = 2; declare @c int = 1; declare @target int = 1; ...
  • 425