2
votes
1answer
16 views

stat report combining data from 3 tables - join or subquery

I have three tables: tbl_Player, tbl_MatchDetails, tbl_MatchStat with some data: tbl_Player CREATE TABLE [dbo].[tbl_Player]( [PlayerID] [int] IDENTITY(1,1) NOT NULL, [Name] [varchar](50) ...
1
vote
2answers
25 views

T-SQL, Select from a few tables with grouping

I have really hard task and I dont know how to start. Lets say we have tables: Car - CarId (int) - OperatorId (int) - ProductionDate (date) Person - PersonId (int) - Name (vchar) ...
0
votes
1answer
56 views

MS SQL - One to Many Relationship - Need to return single row

I have the following tables - Search Result ---------------- SearchResultID PK ProductID FK SearchQuery WebsiteName URL IsFound CreatedOn BatchID Name SearchResultItem ----------------- ...
0
votes
1answer
16 views

Get Updating Value of Column in Trigger

DECLARE @IsDeleted AS BIT = 0; SELECT @IsDeleted = IsDeleted from Updated IF @IsDeleted=1 BEGIN UPDATE Reviews SET IsDeleted = @IsDeleted WHERE CompanyID = 1 END; I want ...
0
votes
4answers
62 views

Multiple Select vs Single Select Statement

I was just wondering whats the difference between doing multiple selects vs. using a single select is there any performance gain? I saw someone did it, and I feel its like kinda out of hand such as ...
1
vote
1answer
32 views

Count the Occurrences of an Attribute?

I have an XML column in a large table that looks like this, in TSQL how would i count the number of times an attribute (LCPID) occurs? Thanks, The code: <soap:Envelope ...
2
votes
4answers
171 views

SELECT COUNT(foreign ID) for each row in datatable

I have datable where I store my dailyContent selection. This is different for each day. When I select more then one day, then I need to return items, which are the same for all days. I have tried ...
1
vote
2answers
37 views

How to print the value with desired text in TSQL using sql server 2005

I want to select a value from my customers datatable. I have been asked this question in an interview. Select cust_Name from customers where cust_Id=5; will result as Naresh. Now I want to print ...
1
vote
2answers
38 views

Select only where all rows for a “customer” have the same status?

I have a status table with a bit field closed I want to try and select all CustomerNumbers where ALL of the rows for that customer are closed The following works...but I'm sure there is a more ...
4
votes
2answers
52 views

How can you perform a join when also using a comma-separated list of tables in an SQL select statement?

This is evidently correct syntax in SQL Server: SELECT a.id, b.name FROM Table1 a, Table2 b WHERE a.id = b.fk1 So is this: SELECT a.id, c.status FROM Table1 a JOIN Table3 c ON a.id = c.fk2 But ...
0
votes
1answer
39 views

T-SQL: logical unique table rows in table

I have simple table containing information about bidirectional links between elements. Table looks like this: link_id | link_side_a_element_id | link_side_b_element_id ...
0
votes
1answer
56 views

load million of rows with optimal performance owing to T-SQL

I want to load million of rows with the best performance using TSQL. I want just to select the primary key. What can help me with SQL Server in addition to adding an index?
1
vote
3answers
125 views

T-SQL get row count before TOP is applied

I have a SELECT that can return hundreds of rows from a table (table can be ~50000 rows). My app is interested in knowing the number of rows returned, it means something important to me, but it ...
1
vote
1answer
67 views

Select From Multiple tables Comma Separated

What is best (low resources and speed)? SELECT C.[col1] , D.[col2] FROM tbl1 C, tbl2 D WHERE C.[colid] = D.[colid] OR SELECT [tbl1].[col1], [tbl2].[col2] ...
1
vote
4answers
106 views

T-Sql: turn multiple rows into one row

How does one turn these multiple rows into one row? N and Y are bool values. Id IsPnt IsPms, IsPdt 1 N Y N 1 N Y N 1 Y N N into this Id IsPnt IsPms, IsPdt ...

1 2 3 4 5 15
15 30 50 per page