Viewing 15 posts - 31 through 45 (of 61 total)
With attachment!
February 9, 2021 at 12:17 pm
Here is an example from my education material. I have not changed names on columns, so you must learn a few danish words - Tid : Time, Navn : Name...
February 9, 2021 at 11:57 am
A general solution with PIVOT.
USE master;
GO
DROP DATABASE IF EXISTS TestDB;
GO
CREATE DATABASE TestDB;
GO
USE TestDB;
CREATE TABLE dbo.Datatable
(
ItemVARCHAR(255),
QuantityINT,
WeekStartDATE
);
GO
INSERT INTO dbo.Datatable VALUES
('WidgetX', 10, '2019-1-18'),-- before
('WidgetA', 10, '2021-1-25'),
('WidgetA', 11,...
January 29, 2021 at 12:51 pm
There may be a difference. If you do not specify ROWS / RANGE BETWEEN ... the default is RANGE BETWEEN. With your definition, it is possible to have duplicates for...
January 4, 2021 at 4:11 pm
You should count both saturdays and sundays.
Buth with your simple math solution, where you only counts sundays, the results is wrong. 2 exampels:
DECLARE @from_date DATE = '11-Oct-2020'; -- sunday
DECLARE @to_date...
October 16, 2020 at 8:52 pm
I'm sure that the table table is in fifth normalform. What do you think it's on (Steve Collins)?
October 1, 2020 at 10:09 am
You can get the information from this select-statement. It shows the size of the table and the size of indexes in 8KB pages.
SELECTi.name,
ps.index_type_desc,
ps.index_id,
ps.index_level,
ps.page_count
FROM sys.dm_db_index_physical_stats(DB_ID('databasename'), OBJECT_ID('tablename'),...
September 28, 2020 at 10:25 am
An "uniquifies" is only an INT (4 byte). It can be a better solution for a table with a lot of NVARCHAR-columns instead of a nonclustered index, if many rows...
September 23, 2020 at 3:27 pm
It's allowed to have a clustered-key as nullable.
CREATE TABLE dbo.t
(
ID1INTNOT NULL
CONSTRAINT PK_t PRIMARY KEY NONCLUSTERED,
ID2INTNULL
INDEX cl_t_ID2 CLUSTERED,
TxtVARCHAR(20)NOT NULL
)
GO
INSERT INTO dbo.t (ID1, ID2, Txt) VALUES
(1, 11, 'aaa'),
(2, 12,...
September 23, 2020 at 1:34 pm
USE master;
GO
DROP DATABASE IF EXISTS TestDB;
GO
CREATE DATABASE TestDB;
GO
USE TestDB;
CREATE TABLE dbo.Table_A
(
col1INT,
col2INT
);
CREATE TABLE dbo.Audit
(
EventDateDATETIME2 NOT NULL
CONSTRAINT DF_Audit_EventDate DEFAULT(SYSDATETIME()),
col1INT,
col2INT
);
GO
CREATE TRIGGER dbo.Dupl_Rec ON dbo.Table_A
AFTER INSERT
AS
BEGIN
IF EXISTS(SELECTTable_A.col1,
Table_A.col2
FROM Table_A INNER JOIN INSERTED
ON...
September 23, 2020 at 11:16 am
"Another thing to note - if Index_ID is 0, it is ALMOST ALWAYS a heap. If Index_ID is 1, it is almost always the clustered index. If it is greater...
September 23, 2020 at 10:25 am
It is a theta-join!
SELECT *
FROM dbo.Sales INNER JOIN dbo.FiscalPeriods
ON Sales.DOCDATE BETWEEN FiscalPeriods.FIRSTDATE AND FiscalPeriods.LASTDATE;
September 14, 2020 at 8:44 pm
I will stop now as it is obviously important for you to prove that tally is the only solution. Your tests are based on the fact that the function tally...
July 25, 2020 at 2:31 pm
Sorry Steve for the slightly short and 'sour' remark, but you obviously did not understand the message. Tally is not a panacea for solving these kinds of tasks. If many...
July 25, 2020 at 12:53 pm
776/5000
"I really appreciate that you have limited resources in Azure". What a comment !!! I am not writing anything about that I have limited resources, but that there are also...
July 24, 2020 at 10:50 am
Viewing 15 posts - 31 through 45 (of 61 total)