Questions tagged [sql-server]
Microsoft's SQL Server is a relational database management system (RDBMS) that runs as a server providing multi-user access to a number of databases. It originated from the Sybase SQL Server codebase, which is why both products use the extension of SQL called Transact-SQL (T-SQL).
577 questions
1
vote
1
answer
65
views
Generate Serial number based on column value in sql server
I have table called cash_voucher it has some columns.
I want to generate voucher number based location id.
I mean generates voucher numbers starting from 1 for each location
For example location id is ...
3
votes
2
answers
81
views
Stored procedure with output parameters in MSSQL
I want a stored procedure that retrieves ID and PID from the invoice table with batchid as input parameter and based on the retrieved PID I want to retrieve sid from the log table.
In total I want to ...
2
votes
0
answers
73
views
Case Study: Database design help for a small app used to coach tennis players
I have a small SQL server database and VBA program that is used to automate tasks related to tennis students, programs, practices, performances, and student testing.
I'm trying to learn db design and ...
1
vote
1
answer
50
views
Filter filtered bike prices twice without repeating yourself
dbfiddle
Goal
Without repetition in the code, I want to filter BikeValuationList to only give the BikePriceId of the latest ...
2
votes
1
answer
165
views
Need assistance in Optimizing the Recursive Query in Pyspark
I am trying to convert a SQL Server stored procedure to Pyspark code.
This is my SQL Server query:
...
3
votes
1
answer
140
views
Creating an array (temporary table) in SQL and iterating through each row within this table to preform a check on the data in each row
The SQL Server version I am using is SQL Server 2008.
I've got an SQL query/script I've written which is to help simplify some things while our API is being rebuilt.
Essentially, this script allows ...
3
votes
2
answers
136
views
Calculate the count of top performers in SQL
I have a transaction table let's call it Offers Table. Please don't read too much into the business but let's say a customer wants to buy a car and the customer searches variety of websites but at the ...
2
votes
1
answer
78
views
Understanding how to properly create a stored procedure that only does INSERT from sourcetable to targettable with dynamic sql
Background and use-case
I need to create a stored procedure where the input parameters will be: @sourceTable, @targetTable, @compositeKey. I'm using available fields for the composite key, since I ...
4
votes
2
answers
167
views
Apply placeholders to an array in a loop for pdo statements for search functions with unknown numbers of keywords
I'm a newbie to PHP and other programming for that matter.
I'm doing this simply to learn. Figured the code could be used to search through a police database or something.
The statements are Microsoft ...
3
votes
1
answer
109
views
Find All Recent Winners and Calculate an Encoding of What They Won
Context
I was proud of this code for a little while, but the repetition wounds me. I know that the function name sucks, but the name and interface to this function are not under my control. ...
2
votes
2
answers
144
views
Find All Recent Winners and Calculate an Encoding
Context
I was proud of this code for a little while, but the repetition wounds me. I know that the function name sucks, but the name and interface to this function are not under my control. ...
1
vote
1
answer
172
views
What is the percentage of customers who increase their closing balance by more than 5%?
The Question
What is the percentage of customers who increase their closing balance by more than 5%?
Source Code
The database and all details can be found here.
ERD
My Proposed Solution
...
2
votes
1
answer
315
views
Efficient Connection Pooling in ODBC-MSSQL with Rust (odbc-api)?
I want to connect to MSSQL using ODBC (odbc-api) at the beginning of my server application created with hyper.rs.
I want to have a connection pool and obtain a connection within each request, which ...
0
votes
1
answer
138
views
Is there a more concise way to write this Procedure
I have this stored Procedure that is passed in the data below that will building the SQL select that will get EXEC. The data that can be passed in can me null so I have three ...
1
vote
1
answer
93
views
Is there a more concise way to write this query in SQL Server?
I'm playing with data from a Time Use survey as a beginner SQL user.
Gender is represented as 1's (Male) and 2's (Female), and the age of each participant is listed. I would like to divide them into ...