Skip to content
Advertisement

Tag: tsql

tSQLt fails when attempting to FakeTable a synonym table

I am using tSQLt (through Red Gate’s SQL Test version 1.0.0.455). tSQLt is installed on database A. I am trying to do a tSQLt.FakeTable on a table in database B on the same SQL server instance through a synonym on database A. Code: ALTER PROCEDURE [ErrorType109NonTankHasSizeOrVolume].[test AliasTest] AS BEGIN Exec tSQLt.FakeTable ‘dbo.Bygning’; Insert Into dbo.Bygning (ObjStatus) Values (1); EXEC tSQLt.AssertEquals

How to sum Accounts

I have 3 tables: DimAccounts, DimTime and FactBudget. DimAccounts example: DimTime example: FactBudget example: In FactBudget are many Accounts just with type B. I need to calculate Debit and Credit Sums where Account type is S (Sum). Columns AccountFrom and AccountTo shows B Type Accounts from where to begin summing (AccountFrom ) and where end (AccountTo). I have made solution

How to test linkedserver’s connectivity in TSQL

I need to write a procedure to collect data from several remote servers, I use linkedservers and OPENQUERY to gather data from servers, but sometimes I lose connection to some servers or I simply can’t connect them (e.g. remote server is offline)- and OPENQUERY results in time-outs in these cases. So I wanted to check linkedservers connectivity first and then

SQL: Join tables on substrings

I have a table A with the string-column a and a table B with the string-column b. a is a substring of b. Now I want to join the the two tables on a and b. Is this possible? I want something like this: Select * from A,B where A.a *”is substring of”* B.b How can I write this in

Remove duplicate data in ‘date-ranged’ rows

I have a table like the following. The date range is used to know for what time period the rest of the Attributes were valid, the problem i have is that there are several consecutive time ranges where the Attributes ramain the same, what I would like is to obtain the same data but without the duplicate rows. From the

Advertisement