Do you want to reset the Windows 2016 administrator password using SQL Server?

This question may sound strange, but my Windows administrator password stopped working on a remote server with a remote desktop (I do not know why, it was running 2 days ago), now it says that the password is incorrect.

No one can physically help the server in 10 days.

I can still connect to the SQL server 2017 in sa mode, is there any way to reset the Windows password through the SQL server?

Anyone can help me suggest or give a sample query to generate this sample output in the SQL server or in the mysql database

enter the description of the image here

Anyone can help me suggest or give a sample query to generate this sample output in the SQL server or in the mysql database

sql server – Total TSQL execution but only based on Logic

You have only been assigned the task of working on an old reservation system that runs on SQL2008r2. Yes, the support for this has ended or soon it will be, but it is as it is.

The vacation hours earned are stored in a table and the reserved Hoilday Hours are stored in another. Due to some limitations of the system, you can reserve more hours that are actually obtained. So my task is to help audit the numbers.

So here is a set of sample data: the expected result is the column that I want to obtain.

Date EmpId HrsEarned HrsReserved Expected result
20160613 100 10.00 -31.70 -21.70 - total <0 so deduct from next row
20160713    100     52.70       -20.00      11.00 -- total >= 0 so do not deduce from the next row
20170613 100 1.00 -11.50 -10.50
20170713 100 16.70 0.00 6.20
20180713 100 5.00 -16.70 -11.70
20180713 100 112.70 -100.00 1.00
20190613 100 0.00 -0.50 -0.50
20190713 100 6.70 0.00 6.20

The rule here is that when the total of HrsEarned and HrsBooked is <0, then deduct this HrsEarned total from the next row. Keep a cumulative total if this results in "Expected result" < 0 on the following row. If the total of HrsEarned and HrsBooked is >= 0, then do not deduct from HrsEarned from the next row.

This is the solution I came up with, this works for the previous example and I get the expected result.

; With cteDATA
AS(
SELECT [ReqId]= 1,[Date]= & # 39; 20160613 & # 39 ;, HrsEarned = 10, HrsBooked = -31.7,[EmpId]= 100 UNION ALL
SELECT 2, & # 39; 20160713 & # 39 ;, 52.7, -20,100 UNION ALL
SELECT 3, & # 39; 20170613 & # 39 ;, 1, -11.5,100 UNION ALL
SELECT 4, & # 39; 20170713 & # 39 ;, 16.7,0,100 UNION ALL
SELECT 5, & # 39; 20180613 & # 39 ;, 5, -16.7,100 UNION ALL
SELECT 6, & # 39; 20180713 & # 39 ;, 112.7, -100,100 UNION ALL
SELECT 7, & # 39; 20190613 & # 39 ;, 0, -0.5,100 UNION ALL
SELECT 8, & # 39; 20190713 & # 39 ;, 6.7,0100
), cteAddRN
AS(
SELECT
RN = ROW_NUMBER () OVER
(
PARTITION OF C.EmpId
ORDER OF C.[Date]
        )
, C.ReqId
,DO.[Date]
        , C.HrsLoaded
, C.HrsReserved
, C.EmpId
SINCE
cteDATA C
)
SELECT
R.EmpId
, R.[Date]
 , R.HrsEarned
, R.HrsReservado
, ExpectedOutcome =
CASE
WHEN R.RN = 1
THEN R.Hrs Booked + R.HrsEarned
WHEN R.RN <> 1 Y ([LAG].Hrs Reserved + [LAG].HrsReceived) <0
SO ([LAG].Hrs Reserved + [LAG].HrsEarned) + (R.HrsEarned + R.HrsBooked)
WHEN R.RN <> 1 Y ([LAG].Hrs Reserved + [LAG].HrsEarned)> = 0
THEN R.Hrs Booked + R.HrsEarned
FINISH
SINCE
cteAddRN R
JOIN LEFT
cteAddRN [LAG]  IN R.EmpId = [LAG].EmpId
And R.ReqId-1 = [LAG].ReqId

However, this fails in cases where, after deducting the total from the previous row, the total of the current row is <0.

Sample of the data set that shows this.

Date EmpId HrsEarned HrsReserved
20160613 100 10.00 -31.70
20160713 100 40.70 -20.00 - Change of Hours: from 52.7 to 40.7
20170613 100 1.00 -11.50
20170713 100 16.70 0.00
20180713 100 5.00 -16.70
20180713 100 112.70 -100.00
20190613 100 0.00 -0.50
20190713 100 6.70 0.00    

The previous query gives the incorrect results

EmpId Date HrsEarned HrsReserved ExpectedOutcome
100 20160613 10.0 -31.7 -21.7
100 20160713 40.7 -20.0 -1.0 --The cumulative total here is <0
100 20170613 1.0 -11.5 -10.5 - It is expected that here it is -11.5
100 20170713 16.7 0.0 6.2 - makes the following rows incorrect
100 20180613 5.0 -16.7 -11.7
100 20180713 112.7 -100.0 1.0
100 20190613 0.0 -0.5 -0.5
100 20190713 6.7 0.0 6.2

php – Advanced SQL Injection Test

As a task for my cybersecurity course, I have been entrusted with the execution of a penetration test in a login form that is meant to be vulnerable to SQL injection and, if we can not do so, we must execute a force attack gross in the form. I have not been successful in searching for vulnerabilities, even when using sqlmap. I was wondering if someone could help me find a better tool or exploitation. Thanks in advance.

database design – Limitations and restrictions of the SQL Server schema

The development team is thinking about using schemas within a database to control the security of different services and tables. As we incorporate 5 different schemas in the database, what limitations or restrictions do we find? What capabilities do developers lose with multiple schemes?

I can only think of one: are there others?

1) For example, indexed views can not be created in different schemes

I did not see them listed in the Microsoft resource:

https://docs.microsoft.com/en-us/dotnet/framework/data/adonet/sql/ownership-and-user-schema-separation-in-sql-server

Grouping by ID and time interval in ms sql

I am trying to write a query that is grouped as identifiers within a period of time.

Real world scenario:
I want to see the rows created by the same ID within 5 seconds of each other.

SELECT the 10 best
I.D,
Created in
FROM Logs
where ((DATEPART (SECOND, OrderCreated) + 5) - DATEPART (SECOND, OrderCreated) <10
GROUP BY
DATEPART (SECOND, OrderCreated),
DATEPART (MINUTE, OrderCreated),
DATEPART (TIME, OrderCreated),
DATEPART (DAY, OrderCreated),
I.D,
Creation date
sort by CreatedDate desc

This is not quite right, but I feel like I'm on the right track.

thanks in advance

sql server: keyboard shortcut to automatically wrap the selected text in IsNull ([text], 0) in SSMS

Is there any way to have a shortcut in SQL Server Management Studio (SSMS) that when text is selected, does that text fit in an IsNull () statement?

For example, I highlight the following text:

My_column_name

and when I click on the keyboard shortcut, what is highlighted becomes:

IsNull (My_column_name, 0)

I write an IsNull after writing the name of the column, probably a dozen times a day, and when I'm at the point of writing, this would be very useful!

The same question posted on StackOverflow: https://stackoverflow.com/questions/56604882/keyboard-shortcut-to-automatically-wrap-selected-text-in-isnulltext-0-in-ss

I am using SSMS v17.4

macos – the SQL server does not start

I have a past Mac that had previously installed mySQL. I tried to run the SQL server from the preferences, but it does not start. The uninstall does not work either. I executed the command sudo /usr/local/mysql/support-files/mysql.server start. It resulted in the following error.

Starting MySQL ./usr/local/mysql/bin/mysqld_safe: line 199: 6557
Trace / BPT trap: 5 env MYSQLD_PARENT_PID = 6140 nohup
/ usr / local / mysql / bin / mysqld –basedir = / usr / local / mysql
–datadir = / Applications / XAMPP / xamppfiles / var / mysql –plugin-dir = / usr / local / mysql / lib / plugin –user = mysql –log-error = APS-16.local.err pid- file = / var / run / mysqld / mysqld.pid – socket = / var / lib / mysql / mysql.sock –port = 3306 < /dev/null > / dev / null 2> & 1 ERROR! The server was closed without updating the PID file
(/var/run/mysqld/mysqld.pid)

I have uninstalled mySql and I have reinstalled it. The error is still persistent.
Commands used to uninstall.

sudo rm / usr / local / mysql
sudo rm -rf / usr / local / mysql *
sudo rm -rf / Library / StartupItems / MySQLCOM
sudo rm -rf / Library / PreferencePanes / My *
sudo rm -rf ~ / Library / PreferencePanes / My *
sudo rm -rf / Library / Receipts / mysql *
sudo rm -rf / Library / Receipts / MySQL *
sudo rm -rf / private / var / db / receipts / * mysql *

sql server – sp_whoisactive @get_locks error xml parameter

I often receive this error when I execute the following command

sp_whoisactive @get_locks = 1

Msg 6841, Level 16, State 1, Procedure sp_WhoIsActive, Line 4287 FOR XML could not serialize the data for the node & # 39; Lock / @ resource_description & # 39; because it contains a character (0x0001) that is not allowed in XML. To retrieve this data using FOR XML, convert it to binary, varbinary or image data and use the BINARY BASE64 directive. Warning: the null value is eliminated by an addition or another SET operation. & # 39;

I think it is related to the capture of the xml of the locks that remain, however, I realize that it happens frequently. Is there a way to avoid this or is it a known problem? Running SQL Server 2012, and the latest version v11.32 of sp_whoisactive.

Why is my SQL Server database file so big?

I have a relatively simple database that has more than 300 MB on the disk. When I look at the data in the table, this adds up to just over 5 MB. Please see the screenshot below:

Screenshot

This screenshot can also be seen here.

If I add several more devices, I will run out of disk space at this speed. Why is it so big and how do I get it and keep it under control automatically?

The results of the "answer" query in this related thread say that the reserved MB should be 7.66, which is still much more reasonable than 300+.