The table should have the following fields:surname,firstname,you please help me with the Mysql statement to do so.
That will go up as you implement additional indexes, but still represents an extremely negligible impact in most systems.
I also always explicitly set things like DATEFORMAT, DATEFIRST, and LANGUAGE to avoid ambiguity, default to English for month and day names, and assume that quarters for the fiscal year align with the calendar year.
If you are using Enterprise Edition on SQL Server 2014 or above, you could consider using In-Memory OLTP, and possibly even a non-durable table that you rebuild using a startup procedure.
Or on any version or edition, you could put the calendar table into its own filegroup (or database), and mark it as read-only after initial population (this won't force the table to stay in memory all the time, but it will reduce other types of contention).
What code do i write so that if i try to add another employee as a general manager, i get an error.
Thank youhi guys, if im going to create a table with derived column(meaning it's value is automatically created based from the value of another column from the table).
Date Dimension WITH (TABLOCKX) SELECT Date Key = CONVERT(INT, Style112), [Date] = [date], [Day] = CONVERT(TINYINT, [day]), Day Suffix = CONVERT(CHAR(2), CASE WHEN [day] / 10 = 1 THEN 'th' ELSE CASE RIGHT([day], 1) WHEN '1' THEN 'st' WHEN '2' THEN 'nd' WHEN '3' THEN 'rd' ELSE 'th' END END), [Weekday] = CONVERT(TINYINT, [Day Of Week]), [Week Day Name] = CONVERT(VARCHAR(10), DATENAME(WEEKDAY, [date])), [Is Weekend] = CONVERT(BIT, CASE WHEN [Day Of Week] IN (1,7) THEN 1 ELSE 0 END), [Is Holiday] = CONVERT(BIT, 0), Holiday Text = CONVERT(VARCHAR(64), NULL), [DOWIn Month] = CONVERT(TINYINT, ROW_NUMBER() OVER (PARTITION BY First Of Month, [Day Of Week] ORDER BY [date])), [Day Of Year] = CONVERT(SMALLINT, DATEPART(DAYOFYEAR, [date])), Week Of Month = CONVERT(TINYINT, DENSE_RANK() OVER (PARTITION BY [year], [month] ORDER BY [week])), Week Of Year = CONVERT(TINYINT, [week]), ISOWeek Of Year = CONVERT(TINYINT, ISOWeek), [Month] = CONVERT(TINYINT, [month]), [Month Name] = CONVERT(VARCHAR(10), [Month Name]), [Quarter] = CONVERT(TINYINT, [quarter]), Quarter Name = CONVERT(VARCHAR(6), CASE [quarter] WHEN 1 THEN 'First' WHEN 2 THEN 'Second' WHEN 3 THEN 'Third' WHEN 4 THEN 'Fourth' END), [Year] = [year], MMYYYY = CONVERT(CHAR(6), LEFT(Style101, 2) LEFT(Style112, 4)), Month Year = CONVERT(CHAR(7), LEFT([Month Name], 3) LEFT(Style112, 4)), First Day Of Month = First Of Month, Last Day Of Month = MAX([date]) OVER (PARTITION BY [year], [month]), First Day Of Quarter = MIN([date]) OVER (PARTITION BY [year], [quarter]), Last Day Of Quarter = MAX([date]) OVER (PARTITION BY [year], [quarter]), First Day Of Year = First Of Year, Last Day Of Year = MAX([date]) OVER (PARTITION BY [year]), First Day Of Next Month = DATEADD(MONTH, 1, First Of Month), First Day Of Next Year = DATEADD(YEAR, 1, First Of Year) FROM #dim OPTION (MAXDOP 1); values are still set to 0.Thanks CREATE TABLE sample.taceledger ( `runno` INT(10) unsigned not null default '0', `doc_no` DECIMAL(6,0) unsigned NOT null , `doc_date` DATE, `gl` DECIMAL(4,0) unsigned not null , `slcode` VARCHAR(6) not null , `tr` VARCHAR(1) not null , `cr_db` VARCHAR(1) not null, `amount` DECIMAL(13,2)unsigned not null , `revcode` DECIMAL(4,0)unsigned not null , `narration` VARCHAR(30)unsigned not null, `cramt` DECIMAL(13,2) unsigned not null, `indi` VARCHAR(1)not null , `dbamt` DECIMAL(13,2) unsigned not null, `acctype` VARCHAR(1) unsigned not null, PRIMARY KEY (`runno`) )ENGINE=Inno DB; I am getting error #1064 on `indi` line I am unable to clear it can u find some solution I'm making a table with employees for a store.Only one employee can be the general manager for the store.We can update most of the stat holidays with a single pass and rather simple criteria: ; WITH x AS ( SELECT Date Key, [Date], Is Holiday, Holiday Text, First Day Of Year, DOWIn Month, [Month Name], [Week Day Name], [Day], Last DOWIn Month = ROW_NUMBER() OVER ( PARTITION BY First Day Of Month, [Weekday] ORDER BY [Date] DESC ) FROM dbo.Date Dimension ) UPDATE x SET Is Holiday = 1, Holiday Text = CASE WHEN ([Date] = First Day Of Year) THEN 'New Year''s Day' WHEN ([DOWIn Month] = 3 AND [Month Name] = 'January' AND [Week Day Name] = 'Monday') THEN 'Martin Luther King Day' -- (3rd Monday in January) WHEN ([DOWIn Month] = 3 AND [Month Name] = 'February' AND [Week Day Name] = 'Monday') THEN 'President''s Day' -- (3rd Monday in February) WHEN ([Last DOWIn Month] = 1 AND [Month Name] = 'May' AND [Week Day Name] = 'Monday') THEN 'Memorial Day' -- (last Monday in May) WHEN ([Month Name] = 'July' AND [Day] = 4) THEN 'Independence Day' -- (July 4th) WHEN ([DOWIn Month] = 1 AND [Month Name] = 'September' AND [Week Day Name] = 'Monday') THEN 'Labour Day' -- (first Monday in September) WHEN ([DOWIn Month] = 2 AND [Month Name] = 'October' AND [Week Day Name] = 'Monday') THEN 'Columbus Day' -- Columbus Day (second Monday in October) WHEN ([Month Name] = 'November' AND [Day] = 11) THEN 'Veterans'' Day' -- Veterans' Day (November 11th) WHEN ([DOWIn Month] = 4 AND [Month Name] = 'November' AND [Week Day Name] = 'Thursday') THEN 'Thanksgiving Day' -- Thanksgiving Day (fourth Thursday in November) WHEN ([Month Name] = 'December' AND [Day] = 25) THEN 'Christmas Day' END WHERE ([Date] = First Day Of Year) OR ([DOWIn Month] = 3 AND [Month Name] = 'January' AND [Week Day Name] = 'Monday') OR ([DOWIn Month] = 3 AND [Month Name] = 'February' AND [Week Day Name] = 'Monday') OR ([Last DOWIn Month] = 1 AND [Month Name] = 'May' AND [Week Day Name] = 'Monday') OR ([Month Name] = 'July' AND [Day] = 4) OR ([DOWIn Month] = 1 AND [Month Name] = 'September' AND [Week Day Name] = 'Monday') OR ([DOWIn Month] = 2 AND [Month Name] = 'October' AND [Week Day Name] = 'Monday') OR ([Month Name] = 'November' AND [Day] = 11) OR ([DOWIn Month] = 4 AND [Month Name] = 'November' AND [Week Day Name] = 'Thursday') OR ([Month Name] = 'December' AND [Day] = 25); (You may have to perform some manual modifications to some of those, in the case where they fall on a weekend - usually the following Monday is marked as the holiday instead.) Black Friday is a little trickier, because it's the Friday after the fourth Thursday in November, and so it might be the fourth Friday, but several times a century it is actually the fifth Friday: UPDATE d SET Is Holiday = 1, Holiday Text = 'Black Friday' FROM dbo.