I have this data set and I need to extract multiple columns values based on on column value. To elaborate on it, I have a rental table, inventory table, customer table, and I want to relate customer …
SQL: Select only rows fullfilling conditions via relation table
I have two tables and I need to select values from first only when all certain conditions are met in second table. Let explain more on an example. First table id movie —|————– …
Sorting Values into Different Columns
I have a table like this: OrderID OrderStatus DateCreated ——————————————– 13 3 2018-10-25 09:33:14.937 13 4 2018-10-25 09:33:19.010 …
SQL – join three table with “where” clause
I want to write an SP that I will use in my c# program. I have three tables: Table1 (id pk, name, …), Table2 (id PK, name, …) and Table3((idT1,idT2) PK FK). So, Table3 models the n:n relationship …
Alter table to add incrementally primary key records where ID values are null
I have a table in sql server with ID field as the primary key. In the rows of the ID field, some have primary key values while some rows do not have primary key values because the ID column allows …
SQL SELECT composite primary key
I have 2 tables User1 and Relationship and it’s some kind of user-friends relationship. I need to find all the friends of a user. For example: I have a user with ID=3 and I need to find all the users …
how to use select into to insert many records
i have a stored procedure that will copy data from table A to table B and return id that is generated from table B to update table a record . this is sample data table A is : id—-Name—refId—…
Query to find tables created in the last hour
I want to find out which tables have been created in the last hour in a MS SQL Server database. How can I do this?
Declare table variable with columns as mush as row in second table
I have a table with id in database. I want to declare table variable with columns as much as id count in the id table(now its 16, but in future it will be more). The columns name must be the id name….
How to extract a hierarchical structure from a flat table?
I want to extract a hierarchical structure from a table in the oracle database. Table look like this: +—-+——–+—————-+———————+ | id | lvl1 | lvl2 | lvl3 …