|
|
|
|
|
|
|
Question of the Day |
Today's question (by Steve Jones - SSC Editor): | |
Consistent Time | |
I have two databases on two different instances. One is in London and one is in New York. Customers log data into these two databases in a table that captures the time that the client inserted the data. All this data is exported into a data warehouse for later analysis. I want to set a default on the table for a column that will automatically capture the time the insert took place, in either location, but in a consistent way. Meaning that if one insert takes place in London at 12:00pm, another takes place in London at 12:02pm, and a third takes place in New York at 7:01am, these are properly ordered. With New York five hours behind, this would mean the data warehouse would have the first London insert, the New York insert, and the second London insert in that chronological order. What should me default be for the column in this table if I want the most precision? | |
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) |
DATETRUNC In SQL Server 2022, there is a new T-SQL function, called DATETRUNC(). What does this do? Answer: This removes all values up to a specified part of the datetime value Explanation: This funciton allows you to truncate down to a particular part of the datetime value. You can truncate to seconds, minutes, hours, days, months, years, quarters, weeks, and more. Everything up to this datepart passed in is kept. Everything after is set to 0. Ref: Datetrunc() - https://docs.microsoft.com/en-us/sql/t-sql/functions/datetrunc-transact-sql?view=sql-server-ver16 |
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 |
AG issue - Few databases are not in sync in an AG as we did not find any errors on secondary replica . any query to check the last log backup on secondary server and databases are in huge size (1TB). How to resync database with primary with out dropping and adding database in primary by restoring full […] |
Blocking with replication monitor - Hi SQL Experts, I opened the replication monitor. I noticed it is causing frequent blocking. When I noticed it is showing create index statements but I didn't create any indexes. What it will happen when you open the replication monitor & why it is causing blocking? |
Log backup job running long time - Hi, We have log backup job running daily 5 times. One time run is taking 4-5 times longer than the other runs daily. The backup size is same for all runs. How can we identify why it is taking long time for that particular time? We have DBCC check job scheduled 2hr before that log […] |
Anonymus user for existing login in SSAS profile - Hi, We have SSAS installed. It is connecting remotely and loosing connection the connection immediately. When I run the profiler when it is first connected it is using the credentials and showing the permissions as OLAPdatareader in the profiler but immediately it is showing as anonymous user in the profiler and lost the connection to […] |
SQL Server 2017 - Development |
Archiving big table - Hey All, We have a very big table which stores transaction data and it is SCD Type 2 table. Records are identified by ID and effective date columns, primary key on these two columns. Table has grown close to 500GB in size with 1.4billion records. 2years ago we had moved records older than 2018/03 to […] |
SQL Server 2016 - Administration |
Permissions for a login - We have a login with a db_datareader only permissions. However, this login cannot see stored procedures in SSMS object explorer and cannot select from sys.procedures (only built-in diagram-related sp are listed there). What extra permissions should we give to a login to be able to see all stored procedures (not to execute them) and still […] |
SQL Server 2016 - Development and T-SQL |
Missing Data(finding the root problem) - I have this function running(see code). I would like to select data beteen dates e.g 30-06-2022 to 31-07-2022. Specificaly for columns Eligible, Fuel Levy, Claimable and % Eligible of purchase. I am gettig zero for these columns. Is my code the reason i am getting these errors or my data missing. More of the views/tables […] |
Development - SQL Server 2014 |
SQL Using a PIVOT to Convert row data to column - Hello, Im trying to get a Pivot to work , but its retuning a NULL . I tried various thing , like using Partition with Row_number as well , the below is the scipt but return null. Basically, I'm looking for the Meshtype to be the column i.e Fine, coarse and Dry to be […] |
SQL 2012 - General |
MS SQL Server 2012 Bible, any opinions on this book? - Hello, the book MS SQL Server 2012 Bible is on O'Reilly's daily deal and I was wondering if anyone had any opinions or thought on it. I have been learning how to work SQL queries and databases at work for a project and am trying to decide if this book is worth buying. |
SQL Server 2019 - Administration |
Command-line installation failure - Detail.txt in use - Hi. I'm having a problem (on 2 different servers) performing a command-line install of SQL2019 with the error: The process cannot access the file 'C:\Program Files\Microsoft SQL Server\150\Setup Bootstrap\Log\20220802_031252\Detail.txt' because it is being used by another process. Any ideas what might be causing this? Thanks. |
SQL Serer 2019 Mikn Worker Thread Calculations - I have looked at Max Worker Threads for SQL Server Always on Availability Group databases And AlwaysOn Availability Groups: What not to do when adding databases I'm trying to calculate minimum required worker threads on the primary using this formula: SELECT AG = D * (LCWT + (LSWT * SRC)) +MHWT Knowing that I have […] |
SQL Server 2019 - Development |
Count a new field in SQL statement - Hello all, I am trying to find a query that bring results like on the example. Thanks a lot all and best regards, |
Calculate a new field in SQL statement - I have need calculate new field on this logic Is there way to do in SQL instead of procedure or function We have invoice id and item line item and we have credit memo which apply to line item Line Item 1 = 2098.76 Line Item 2 = 699.59 Apply CM Amount -2798.35 to both […] |
SQL Azure - Administration |
Password management in SQL MI for Sysadmin account - Hi, I've a requirement to provide temporary access for a sysadmin account. Each time a user requires access, temporary password needs to be created for the specific login. I've heard Password management tools like Cyberark can be used for it. Is there an inbuit tool for SQL MI password management or any open source tool […] |
Amazon AWS and other cloud vendors |
New to AWS - I am very new to AWS and trying to figure out how to do a few things but I am getting a bit overwhelmed. I have code that I put on an EC2 instance and it is connected to RDS. I can look up the EC2 generated url and see the data I expect to […] |
| |
©2019 Redgate Software Ltd, Newnham House, Cambridge Business Park, Cambridge, CB4 0WZ, United Kingdom. All rights reserved. webmaster@sqlservercentral.com |