Skip to content

Tag: sql-server

How do I write a case statement to return duplicate records?

I have a table of names and addresses and want to return the full list of names and addresses with an extra column that identifies if the address is a duplicate or unique address. There are several duplicate address entries that I can see when I run a more simple statement — or but I need to return the …

Wrong Opening Balance for some rows

I want to calculate Opening and Closing Balance of a business application. But for some rows wrong Opening Balance is producing. I have following Data Tables: SupplierPayments DateOfPayment Bill …

Dynamic SQL Select variable name

I have the following SQL statement, which works fine: DECLARE @TableName VARCHAR(250); SET @TableName = ‘TBL_Name’ SELECT QUOTENAME(@TableName) As TableName, HASHBYTES(‘SHA1’, (SELECT * FROM TBL_Name …