|
|
|
|
|
|
|
Question of the Day |
Today's question (by Evgeny Garaev): | |
Restore databases on SQL Server 2017 | |
You have restored a database from a full backup on a SQL Server 2017 instance with NORECOVERY option. Now you need to apply a differential backup. Which T-SQL command would you use? | |
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) |
Finding the username In Python, I have this code that runs: >>> str = """EmailAddr,Nickname,Role ... sjones@sqlservercentral.com,Steve,Admin ... webmaster@sqlservercentral.com,Webmaster,Admin ... pressrelease@sqlservercentral.com,Press,author ... """ I now want to use a regular expression to find the username in the email. I run this: >>> for i in re.finditer('([a-zA-Z]+)@([a-zA-Z]+).(com)', str): ... print(i.group(xxxx)) What should replace the "xxxx" to get the username from the email address? Answer: 1 Explanation: The regular expression method, finditer, will break this out to find email address matches. The 0th element in the group is the full match, i.e., sjones@sqlservercentral.com. The index of 1 gets the username, i.e. sjones. The index of 2 gets the domain, i.e. sqlservercentral. The index of 3 is the "com" element. Ref: Regular Expression Operations - https://docs.python.org/2/library/re.html |
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 |
TLS 1.2 and Database mail - Hi, We use office 365, and just recently received an email from them saying we had a client using TLS 1.0. I tracked this down to database mail. I'm an accidental DBA (more a developer, but now a jack-of-all-trades IT), so don't know about security at all. We have MSSQL 2017 on Server 2016. One […] |
SQL Server 2017 - Development |
Group and total by column Name - Guys, How do i group the below by type and date so i have a total for each day for each person by each type. So the desired results should look like: INTO #SampleData2 FROM ( VALUES ('2019-01-01', 'Dave', 'Break', 797), ('2019-01-01', 'Dave', 'Break', 746), ('2019-01-01', 'Dave', 'Break', 511), ('2019-01-01', 'Bethan', 'Break', 631), ('2019-01-01', 'Bethan', […] |
What is wrong with my code? - Here is my code: CREATE TABLE ProjectCodes ( ProjectID varchar(22), ProjectName varchar(25), Level char(1), [Project Classification] varchar(14), [Project Type] varchar(11), Billable char(1), DEFAULT 'Y', [Allow Charging] char(1), DEFAULT 'Y', Active char(1), DEFAULT 'Y', [Contract No] char(17), [Task Order No] char(17), CONSTRAINT PK_ProjectCodes_ProjectID PRIMARY KEY CLUSTERED (ProjectID ASC) ) The error message is: Msg 142, […] |
SQL Server 2016 - Administration |
tempdb space reduction - How can we minimize the space utilization of tempdb when we ran the dbcc integrity/check db jobs ? we are geeting space issues every week when these jobs are running in weekends. if we choose sort in tempdb =off will it save the disk space where tempdb resides? |
-ExcludeJob with list dbatools - Hello everyone , I would like to transfer job sql lists through dbatools through the Copy-DbaAgentJob command only I want to exclude a list of jobs the lists is a long thank you for your help $Source = 'production\REF ' $Destination = 'localhost' $SharedPath = '\\production\migration' Copy-DbaDatabase -Source $Source -Destination $Destination -Database exploit -BackupRestore -SharedPath […] |
How to send queued emails - After an upgrade, sql server stopped sending emails. Problem is not solved but during the breakdown some emails were not sent. I can see them with this query: SELECT * FROM msdb.dbo.sysmail_unsentitems; The status is: unsent Is there a way to sent them now that the problem is fixed? thanks |
SQL Server 2016 - Development and T-SQL |
Long name in TSQL is creating errors - Hello, This will be a simple problem to solve for many of you! I am sure of it I have a script created in SQL agent and when I run it with a simple path it works but not with the long name: SET @path = 'C:\SQLBackup\' SET @path = 'C:\Users\Administrator\OneDrive - My Company […] |
DATEADD(DAY, -30, GETDATE()) - Dear Everyone I wanted to know the statement below will it delete everything in the last 30 days or anything before the last 30 days? DELETE FROM tb_LogIP WHERE MsgLogID IN (SELECT MsgLogID FROM tb_LogGeneral WITH (NOLOCK) WHERE CLF_LogReceivedTime < DATEADD(DAY, -30, GETDATE())) I think this query will delete the most recent data in the […] |
Administration - SQL Server 2014 |
Adding server to Alwayson - Hello Experts, For the first time i got a oppurtunity to work on Alwayson setup at configuration level.Till now already its configured and was maintaining and monitoring the Always on dbs. I am exited to perform below task. As it is a production servers with more than 2TB size i am seeking help from you […] |
Development - SQL Server 2014 |
Left join not pulling all from left table - T has 57,000 distinct rows Z has over a million. I did row over partition on the key field (Z.zpsh) When i run the following SQL, I only get 47,000 rows back. Shouldn't I get 57,000? thanks select * from #temp1 T left join #temp2 Z on T.entry = Z.zpsh where z.rownumber = 1 |
SQL 2012 - General |
Upgrading tables without downtime - Hi, We are in the process of a larger upgrade of an existing database. Basically we are normalizing some of the tables which means we need to copy data from old table(s) to new table(s). The data migration is planned to be done from within an external application that reads from the old tables and […] |
SQL Server 2008 - General |
how to get 0 if records have empty or null values when column datatype is numeri - Hi I have one doubt in sql server how to get 0 when records have empty or null values when column datatype is numeric in sql server else get max(id) values in sql server Table : empid CREATE TABLE [dbo].[empid]( [id] [numeric](11, 0) NULL ) ON [PRIMARY] GO INSERT [dbo].[empid] ([id]) VALUES (NULL) GO INSERT […] |
Reporting Services |
Bulk Export of History Reports - We are shutting down a SQL Server and would like to know if there is any way to export the History Reports from Report Manager so they can be saved as either Excel, CSV or pdfs? Any suggestions? The data is being moved to new server however the reports on that new server are different […] |
Integration Services |
ForEach Loop shows Success before Completing all loops - I have an SSIS package I set up years ago and it always ran fine until recently. There is a ForEach Loop Container. Each loop runs a stored procedure (the stored procedure creates synonyms to point to a database), then loads a table from the data in that database. I have a lot of these […] |
How to run package (catalog) from PowerShell with Environment variable in DTExec - Hello Everyone, I am new to PowerShell. I don't even know the basics. I have used the below script and able to run the package successfully. But the problem with this script is it just triggering the package and returning the execution id. Not sure whether the package got succeeded or not. https://docs.microsoft.com/en-us/sql/integration-services/ssis-quickstart-run-powershell?view=sql-server-2017 Later I […] |
| |
©2019 Redgate Software Ltd, Newnham House, Cambridge Business Park, Cambridge, CB4 0WZ, United Kingdom. All rights reserved. webmaster@sqlservercentral.com |