|
|
|
|
|
|
|
|
Question of the Day |
Today's question (by Steve Jones - SSC Editor): | |
Dropping Columns | |
I have a table in a SQL Server 2017 database that looks like this: CREATE TABLE ArticleSeries ( SeriesID INT NOT NULL, ArticleID INT NOT NULL, ArticleOrder TINYINT NOT NULL, ArticleAbstract VARCHAR(200), ArticlePublishDate DATE ) GOI have decided the ArticleAbstract and ArticlePublishDate can be removed as they are stored in another table. Can I delete them like this or do I need two batches? ALTER TABLE dbo.ArticleSeries DROP COLUMN ArticleAbstract, ArticlePublishDate GO | |
Think you know the answer? Click here, and find out if you are right. |
Yesterday's Question of the Day (by Steve Jones - SSC Editor) |
The Deleted Table Name I have built a DDL trigger to capture the drop of a table to prevent dropping a particular table. My trigger looks like this: CREATE TRIGGER NO_DROP_ImportantTable ON DATABASE FOR DROP_TABLE AS DECLARE @Table SYSNAME; SELECT @Table = ??? IF @Table = 'ReallyImportantTable' ROLLBACK; GO What should I put in the SELECT statement in place of the question marks? Answer: EVENTDATA ().value ('(/EVENT_INSTANCE/ObjectName)[1]', 'sysname'); Explanation: There are no inserted or deleted tables in a DDL trigger. Instead, data is captured and retrieved using the EVENTDATA() function. Ref: |
Database Pros Who Need Your Help |
Here's a few of the new posts today on the forums. To see more, visit the forums. |
SQL Server 2017 - Administration |
question on parallelism - Hi All, We have 16 CPU's, 256GB RAM Azure VM on which SQL Server 2017 is running. Our workload runs pretty well when MAXDOP = 1 and when we try to set the MAXDOP = 4 or MAXDOP = 8, we start seeing deadlocks all over and application team start complaining about slowness of some […] |
Pagesplits question - Hi All, Does a DELETE operation cause PAGE Split? As far as I know we Page splits occur for only INSERT and UPDATE. monitoring for operation : LOP_DELETE_SPLIT Thanks, Sam |
SQL Server 2017 - Development |
How to query performance baseline - Hi All, We don't have baselines in our env. I mean, no monitoring tool. We use sp_whoisactive every 5 mins. Currently, we are facing some query performance issues. Want to know what are the things to be considered or how to take query performance baselines? like rows counts, indexes, execution plans etc.. Also, suppose I […] |
How to stop an XE after 2 hours automatically - Hi All, I want to start extended session via job and want it to stop automatically after 2 hours. How to accomplish it? ALTER EVENT SESSION ON SERVER STATE = START; GO ALTER EVENT SESSION ON SERVER STATE = STOP; GO Thanks, Sam |
How to get the transaction mode of a spid. - Hi All, Which DMV will tell me the transaction mode of a SPID? I did check MSDN but couldn't get the answer. https://learn.microsoft.com/en-us/sql/relational-databases/system-dynamic-management-views/sys-dm-tran-session-transactions-transact-sql?view=sql-server-ver16 - Autocommit transaction - Implicit transaction - Explicit transaction - Batch-scoped transaction - Distributed transaction Regards, Sam |
Administration - SQL Server 2014 |
Can't start SQL Server - I have a system with two disks in the C: drive and four disks in a RAID 5 setup for the D: drive. A few weeks back, one of the D: disks failed. No sweat, ordered another, plugged it in and let the RAID rebuild overnight. All seemed to be fine, I can log in […] |
SQL 2012 - General |
SQL Server 2012 Standard Media/ISO - Does anyone have a copy of SQL Server 2012 Standard handy? I just need the ISO or DVD contents to install on a new server. I have the key already from the old server, but we don't have the media any longer. I checked online and can't seem to find a good place to download […] |
SQL Server 2019 - Administration |
Upgrade to 2019 express from 2012 express check failed - Hello, I would like to upgrade my SQL Server 2012 Express instance (10.0.2100) to 2019 Express, but during the verification checks, I receive an error stating that Service Pack 2 is required to proceed. The issue is that I cannot find any SP2 for Express. Do I need to use the standard version instead? […] |
SQL Server 2019 - Development |
receiving duplicate key error when adding new records - I administer a database for a local chapter of a national group. The National group does not provide local chapters access to a database but does give us a csv file which i then used to export to an Excel spreadsheet with all the members listed in it. I then imported that table into my […] |
Find value of next row upon condition - In the following table, I want to replace the zero in the column idPointsrv by the next row that is not a zero in this case replace all zero by 316770 Thanks in advance for your help |
Using A CTE to exclude rows from the main Select statement - I have a cte that in short states SELECT mm.id1 mm.date ,mm.Datecompleted ,mn.number FROM table1 as mm left join table2 as m on mm.type = m.type left join table3 as mn on mm.id1 = mn.id1 where 1=1 and type = 29 and date is null and Completed = 1 I then have a select statement […] |
General |
Informatica SQL generating basic statement - I'm newbie using Informatica Data Quality Analyst and am unable to create a basic SQL statement. The Sql query is being created against a mapping specification of a table that was imported as a flat file originally. The statement is as follows: Select ColumnA, ColumnB FROM Table1 WHERE Table1.ColumnA = 'S' That SELECT.... FROM part […] |
Anything that is NOT about SQL! |
Windows Server Alert When Service Doesn't Start - Not Working - I am trying to send an email when a Windows service doesn't start. What I did: I wrote a batch file that runs a short Powershell script to send an email. It works fine if I run the batch file by itself. I get an email. I have a service on my laptop set to […] |
Employers and Employees |
Microsoft Sql Server DBA Salary - Full time vs Contract - I have 10 years of experience as regular full time employee as MSSQL DBA - unfortunately, with a small company with some 20+ on premise servers running about 100+ databases with no HA or clustering experience. The earlier roles before the DBA role, I was in tech support and web development. Comparing my salary to […] |
SQL Server 2022 - Development |
Schedule a PowerBI dataset refresh on the "quarter" hour ??? - Hi all, I know very little about Power BI, but I am hopeful that someone here has enough knowledge to know whether or not it is even possible to schedule a dataset refresh on the quarter-hour instead of merely on the half-hour or top of the hour. I know that with SSRS, I can use […] |
| |
©2019 Redgate Software Ltd, Newnham House, Cambridge Business Park, Cambridge, CB4 0WZ, United Kingdom. All rights reserved. webmaster@sqlservercentral.com |