2
votes
3answers
44 views

How to join these two queries?

This query gets several AssignmentId's SELECT AS2.AssignmentId FROM dbo.AssignmentSummary AS AS2 WHERE AS2.SixweekPosition = 1 AND AS2.TeacherId = 'mggarcia' This query gets a value for only one ...
0
votes
1answer
23 views

How to get distinct column data on the basis of latest date time from SQL Server 2008 R2

I have table login with columns id, username, logindate. Sample data looks like this: {1, username1, logindate1} {2, username2, logindate2} {3, username1, logindate3} {4, username2, logindate4} ...
3
votes
1answer
38 views

SQL: find continuous date ranges across multiple rows?

I'm trying to get a start and end date combination for continuous spans of time worked. The spans can cross multiple rows, where the end date of the first row is the same as the end date of the next ...
0
votes
1answer
12 views

How to use column name as part of a LIKE statement in a WHERE clause of a JOIN

LEFT OUTER JOIN [INVENTTRANS] ON #TEMP.VOUCHERPHYSICAL=[INVENTTRANS].VOUCHERPHYSICAL WHERE [INVENTTRANS].ITEMID = #Temp.INVENTDIMID This provides me nearly the result I am looking for. About 1/4th ...
0
votes
1answer
28 views

Calling a SP from another SP via EXECUTE SP_EXECUTESQL

I am using EXECUTE SP_EXECUTESQL for calling a stored procedure from another stored procedure but I am getting an error. I haven't tried it before so I don't know what is wrong. Here ...
-4
votes
2answers
38 views

SQL query row number for a group

I have a resultset like this ID Name theDate 123 AAA 01/01/2012 123 AAA 01/02/2012 123 AAA 01/01/2012 456 BBB 02/04/2012 789 CCC ...
0
votes
1answer
23 views

Update DATETIME values to <= GETDATE()-1

I'm looking to update existing DATETIME values to yesterdays date and previous depending on their DATE order but keep the TIME part as it is. For example assuming today's date is 2013-05-15 ...
0
votes
4answers
58 views

Getting count of records in child table using select statement

I have a stored procedure in which i am trying to select all the columns of a table Table 1. There is another table which uses Table1 primary key as foreign key. I want to count number of records in ...
3
votes
3answers
74 views

SQL Query to calculate first n customers based on quantity conditions

I have a question but I am not sure how to ask. Here is my example. Product Customer TxDate Qty Apple Peter 2013/02/02 3 Apple Edward 2013/02/03 5 Apple Sally 2013/02/06 3 ...
1
vote
2answers
40 views

How can I substitute IDs in a string with corresponding values from a table?

I've got 2 tables in a SQL Server 2008 R2 database - Rules and Items A Rules record has Id and Expression, eg: 1, "(1 AND 2)" An Items record has Id and Name, eg: 1, "Foo" 2, "Bar" Is ...
-2
votes
1answer
39 views

how to replace overflows with NULL? [closed]

how do i replace an invalid datetime with null? I am doing some operations on an INT column that is actually a date representation: select DATEADD(DD, rbaging.billing_period_end - 693594, ...
0
votes
0answers
16 views

Update Multiple Values In Xml with .modify method

I have looked over release documentation for the 2012 SP1 release of Sql Server and reviewed this old post. TSQL 2005, XML DML - Update Two Values at once? I am wondering is it possible to ...
3
votes
2answers
55 views

Dynamically create ranges from numeric sequences

I have a table like the following: +----+-----+-----+ | ID | GRP | NR | +----+-----+-----+ | 1 | 1 | 101 | | 2 | 1 | 102 | | 3 | 1 | 103 | | 4 | 1 | 105 | | 5 | 1-2 | 106 | | 6 | 1-2 | ...
-1
votes
1answer
70 views

SQL Server : duplicate rows with ID < 0 and get new created ID

I have recovered a table from MS Access inside SQL Server 2008 R2. The old table in MS Access was using a PK with replication type integer (so there's negative values) After importing the table into ...
-1
votes
2answers
40 views

What does the third parameter in CONVERT() do?

Query Get the Joining year,Joining Month and Joining Date from employee table This is my query which I have to perform. For this I write the following script: select SUBSTRING ...

1 2 3 4 5 37
15 30 50 per page