Viewing 15 posts - 1,246 through 1,260 (of 1,491 total)
I was thinking along the lines of:
SELECT *
FROM Employee E
JOIN (
SELECT ROW_NUMBER() OVER(PARTITION BY B.EmployeeId ORDER BY B.BillId DESC) AS Row
,B.BillId
,B.BillAmount
,B.BillMonth
,B.EmployeeId
FROM EmployeeBill AS B
) D ON E.EmployeeId = D.EmployeeId
WHERE D.Row...
March 16, 2007 at 4:58 am
Try something like the following. The UPDLOCKs are important to avoid deadlocks.
UPDATE I
SET Status= 1
,@IdentPK = I.Identpk
FROM pIdent I
JOIN (
SELECT MAX(D1.IdentPK) AS IdentPK -- will ignore NULLs
FROM (
SELECT MIN(I1.IdentPK) AS...
March 15, 2007 at 9:46 am
I find your question confusing.
You are more likely to get appropriate help if sample data and expected results are provided.
Maybe you want something like:
DECLARE @EndDate smalldatetime
,@StartDate smalldatetime
SET @EndDate = CAST(CONVERT(varchar(6),...
March 13, 2007 at 12:15 pm
Try looking up ROW_NUMBER() OVER(PARTITION BY ... in BOL.
March 12, 2007 at 3:26 am
My solution does need some error handling. (sp_releaseapplock in CATCH block etc)
Also, it would probably be better to use the SP name plus the @HashedBasketId for the resource just in...
March 8, 2007 at 9:56 am
If this is part of the
http://www.sqlservercentral.com/forums/shwmessage.aspx?forumid=360&messageid=346291
thread:
1. I would put the index on the FK and let the optimizer work out whether to use a MERGE or LOOP join based...
March 8, 2007 at 7:59 am
Opps,
See you have already done that.
March 8, 2007 at 5:17 am
Consistent use of application locks helps in this sort of situation.
Try something like:
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE PROCEDURE [dbo].[ST_BASKET_INSERT]
@BasketId int OUTPUT
,@HashedBasketId varchar
March 8, 2007 at 5:15 am
I suspect the problem is that CREATE LOGIN does not accept a variable for the login_name so a variable will not work within sp_executesql. (I do not have access to SQL...
March 7, 2007 at 10:28 am
A BatchID could also be generated from a dummy IDENTITY table. Something like.
CREATE TABLE dbo.BatchIDs
(
BatchId int IDENTITY NOT NULL
)
GO
DECLARE @BatchID int
BEGIN TRAN
INSERT INTO dbo.BatchIDs DEFAULT VALUES
ROLLBACK
SELECT @BatchID = SCOPE_IDENTITY()
-- SELECT...
March 7, 2007 at 7:36 am
Get rid of Enumerations and have separate tables for States, Countries etc.
March 7, 2007 at 6:30 am
Maybe:
SELECT @result = DATEDIFF(day, MIN(StartDATE), MAX(EndDate))
FROM @MyTable
March 7, 2007 at 6:23 am
SELECT REPLACE(STR(MONTH(GETDATE()), 2), ' ', '0')
March 7, 2007 at 6:08 am
In this situation, Remi's outline solution is best.
You should however use an UPDLOCK on the select in the derived table. Ensuring that only one of the processes can read the...
March 7, 2007 at 4:58 am
I think you need to put an UPDLOCK in the derived table in order to guarantee that only one transaction can read the rows. Also, there may as well be...
March 6, 2007 at 7:16 am
Viewing 15 posts - 1,246 through 1,260 (of 1,491 total)