I have a remote MySQL DB in a hosting that I need to export to my local SQL Server. I use Heidi SQL to connect the DB and I use the Export to single .sql file The problem is that the DB is 5GB and the .sql file is 2.3GB. So I can’t open the .sql with SSMS because it
Tag: sql-server
Find Row with closest date for each item in list in SQL Server
Dear all unfortunately I could not get the solution in this Post to work for my Problem. I have a Table which stores Prices for each ID and attaches a Date. When the Prices are update a new Entry is generated, hence this talble contains mutliple historic Prices for each ID. Now I want to find for each Item in
Select in a select from another table [closed]
Closed. This question needs debugging details. It is not currently accepting answers. Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question. Closed 6 months ago. Improve this question I ne…
SQL few running total at different stops
Note: I am bringing up a problem to which I have a solution, the purpose of the question is to see if there is a better one. I have customers that make transactions. I want for each customer to know when did they reach 3K, 5K and 7K (or any other threshold). End result is: I was wondering if I
Count rows within date range with condition
I’m not sure that this issue can be solved in SQL server, but I decided to ask you anyway. Let’s create a table and add some random variables: Now, let’s add to the table two columns: “before_5” – five minutes before the given timestamp “after_5” – five mi…
SQL case expression divide values for percentage
I’m trying to divide two values to get the percentage. I need the ‘VA’ AUM / ‘TOTAL’ AUM to get the percentage. Below are the two different methods that I have tried, but they are not providing the percentage. The first method only provides ‘NULL’. How do I take the p…
Complex Conditional Query in Where Clause
In my company, each department has their own statuses for purchase orders. I’m trying to load only the pertinent POs for a specific user’s department. I keep getting errors. It seems like it should be correct, though. I initially attempted to use a Case statement, but it appears that SQL can only …
How to check consecutive values in rows in TSQL?
I have the following table: And I am looking for an output like this with a consecutive available two slots. Preferably the consecutive number should be a variable like @n = 2. How to achieve this in TSQL? Thanks! Update 8/3/2022: I undeleted this question as it is not fair to @lptr, as he/she has the correct…
T-SQL Calculating Time Quarters
I would like to parse this record across quarter buckets and the length spent in each quarter bucket. Answer Just another option … BRUTE FORCE Example or dbFiddle Results
Consolidate Rows with SQL
Trying to consolidate test results so that each test is in one row. Database I am pulling from has an answer result per row. Sample Data: Student Name Test Name Question Attempt Answered Correctly (0 = no, 1= yes) Mary Intro Assessment 1 1 Mary Intro Assessment 1 0 Mary Intro Assessment 1 1 Joseph Intro Asses…