I’m having trouble with selecting the highest aggregated group. I have data in a table like this: Sales table: ID GroupDescription Sales 1 Group1 2 1 Group1 15 1 Group2 3 1 Group3 2 1 Group3 2 1 Group3 2 2 Group1 2 2 Group2 5 2 Group3 3 2 Group4 12 2 Group4 2 2 Group4 2 I want
Tag: ssms
Export MySQL Database from HeidiSQL to SQL Server. Problem with simple quotes
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
using Query one results to run Query two
This code would result with this Result What I would like to do is when the code above gets the results my bottom code reads them and runs them trough its code. The common denominator here would be the account number because its running through a different table I have tried doing this the code below but it doesnt seem
How can I generate an ID column for a column in SQL? [closed]
Closed. This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 6 months ago. Improve this question I have a column that I’d like to generate an ID column for. How can I do this using SQL?.
Insert data into a table from Open Query with variable
I am trying to using OPENQUERY to pull some data into a table. Here’s what my code looks like: I end up with the following error: An INSERT statement cannot contain a SELECT statement that assigns values to a variable. When I attempt to run the EXEC(@TSQL) without the INSERT it works like a charm, but I am unable to
Correct database after backup
I need some help with a query. Actually we have some wrongs DATA in our database. For some technical reason I restore the backup in another schema. So actually in my Schema1.DB1.TBL1 I got the backed up DATA and in my Schema2.DB2.TBL2 I have the same table but with some wrongs DATA. Could you please tell me an SQL query
execute powershell from SSMS
I am trying to execute as certain xp_cmdshell code: but this is the error that I get: when I try an execute the same thing in powershell I get the expected response(see image) Powershell The expected output from the xp_cmdshell should be a json Answer The error message implies that your command line is being executed via cmd.exe, where &
Get Start and End date from multiple rows of dates, excluding weekends
I’m trying figure out how to return Start Date and End date based on data like in the below table: Name Date From Date To A 2022-01-03 2022-01-03 A 2021-12-29 2021-12-31 A 2021-12-28 2021-12-28 A 2021-12-27 2021-12-27 A 2021-12-23 2021-12-24 A 2021-11-08 2021-11-09 The result I am after would show like this: Name Date From Date To A 2021-12-23 2022-01-03
SQL Row Data to Column Data in Join
Trying to wrap my tiny brain around how to write this query and I am at a loss: Current: How I would like it to look: If someone can point me to a function that could help me with this, it would be much appreciated. I already tried using: max(case when ….) and pivot() which I found in other articles,
Adding x work days onto a date in SQL Server?
I’m a bit confused if there is a simple way to do this. I have a field called receipt_date in my data table and I wish to add 10 working days to this (with bank holidays). I’m not sure if there is any sort of query I could use to join onto this table from my original to calculate 10