I’m using sql server and I have a table named Table that looks like this. SenderId ReciverId ItemCount 1 2 5 1 4 3 1 6 4 2 1 2 2 5 6 3 1 1 4 3 7 4 5 4 5 2 6 5 4 2 5 6 6 6 4 3 I want to make groups of
Tag: sql-server
Import specific values from csv files to column of existing table
I am trying to figure out how to create a query/tsql that can import values from csv file to existing table. This is example how few records of csv looks like: And my existing table in SQL Employee table All columns already have values except SupervisorId (supervisorId is a foreign key that points at main key…
Using Join and Union to combine results from 2 tables [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 9 months ago. Improve this question I already have a result set using join from multiple master tables with T…
How to only run left join when the variable is not null?
I’m trying to simplify my stored procedure and I have one that is only using left join based on the user id that is passed in. If the user id is null, don’t do left join, but if it is null, left join it with another table. How should I re-write it ? Thank you Answer Currently your stored procedure
T-SQL :: information_type is not parsed in SQL Server 2019
My query doesn’t seems to parse information_type STEP TO REPRODUCE: Take AdventureWork or any other test database Right click on your test database > Tasks > Data Discovery and Classification > Classify Data… and classify a bunch of data Now use this query to check your information_type c…
T-SQL :: generate random Swiss National Identification Number (AHV/AVS)
I woul like to generate random Swiss National Identification Number (AHV/AVS). I found a website that can do that and if I look at the source code of the same page I can alos see the JavaScript code that can generate it. The numbers are generated following this pattern: 756: is the prefix number, it never cha…
Why SQL (On-Prem using Data Gateway) Insert row (V2) action in Logic App does not populate tables?
I have an On-Prem SQL which I am accessing in my Logic App using On-Prem Data Gateway. I have created a table in my SQL database as per below: From a Logic App, I am trying to insert rows using “Insert row (V2)” action but it does not populate any tables: If I try any other SQL action in a
Validation trigger not working in SQL Server
I am working on a trigger for a class project. I have a table named salesman with a column named type. All employees in the table currently have a type of full, part or temp. The purpose of the trigger is to check a newly inserted row’s type and make sure that it matches one of the three that already
How to pull rows from a SQL table until quotas for multiple columns are met?
I’ve been able to find a few examples of questions similar to this one, but most only involve a single column being checked. SQL Select until Quantity Met Select rows until condition met I have a large table representing facilities, with columns for each type of resource available and the number of thos…
How to select rows from table when a column repeats?
I have this table (REGIONS) with this sample values: Id Cod1 Cod2 Payed 1 0001 000A NULL 2 0001 000B YES 3 0001 000B YES 4 0001 000C NULL 5 0001 000C YELL 6 0001 000D NULL 7 0002 000A YES 8 0002 000C NULL 9 0002 000C NULL 10 0002 000C YES 11 0003 000C YES 12 0004 000C