I want to insert some data in Table1 in my database selecting it from another Table2 but the Table1 has another attribute for username (ComputerName). What I have tried: Answer I think you are looking for something like this :
Tag: sql-server
Inserting data row into a sql table from another sql table in C#
Context: I’m developing an app for windows in Visual Studio that has a table of stock materials and another of buyed materials, both in a Sql Server. I want that every time you buy something it is added into the stock table. I’m new in using SQL with c# combined. I’m trying this from a tutor…
How to connect to a Azure SQL Server through Python
I’ve come across some trouble accessing my SQL Server through Python. I can get it going when my SQL Server is installed locally, but not when it is online. I have used the following code: Connection to SQL Server but then when I try and run: I get the error: InterfaceError: (‘IM002’, ‘…
SQL pivot count and sum 2 columns
I have a table shopid times times2 shop1 5 1 shop2 2 2 shop1 6 1 shop1 1 1 shop2 1 2 Query and I got count correct for column Times Select [shop1], […
week number as column name
first of all my sql statement: SELECT DISTINCT ( SELECT SUM(Preis1) FROM tblBuchungsdaten WHERE (Datum BETWEEN DATEADD(wk, -7, DATEADD(DAY, 1-DATEPART(WEEKDAY, GETDATE()), DATEDIFF(dd, 0, …
Selecting records in SQL table if either JOIN statement is satisfied
I have a table of Companies that I’d like to filter to just the records that are referenced from two other tables, Employees and Contracts. My initial instinct is that I might be able to do something …
window functions and grouping – how to propagate data from row 1 through row 3 in a partition?
I have this query below: select Contact.IndividualID, Contact.IndividualID as ContactId, Contact.CaseNumber as CaseID, [Case].ProgramCode as Benefit, Contact.Email as EmailAddress, …
Cumulative balance across two tables
I want to get data from 2 tables ordering them by date: to get the cumulative balance for the customer The 2 tables that I want to get data from are my tables: transfers & trans_payments transfers:…
Pivot table in SQL Server 2016
I am having problem with pivoting a table in SQL Server 2016. Consider the following data/query WITH DATA1 AS ( SELECT 123 cid, ‘test’ cname, ‘2020-03-17’ dt, ‘BELLE’ fc, 3782703 mn union …
How to repeat previous row values until another field changes
I am trying to repeat a value from one row if there is no change between a column value in the row before. Thanks in advance! create table #results ( [Floor] varchar(20) ,Room varchar(20) …