Home > database >  SQL statements in powershell is carried out
SQL statements in powershell is carried out

Time:03-19


I want to pass the powershell script to connect MSSQL database, execute the following command, it is concluded that a value, if the value is greater than 50 the output 1, less than 50 0, use the powershell scripts to perform this operation


Urgent need, please leaders to help, plus Q can send red envelopes, 1564837491

The following is a statement,
Declare @ totalNo int
Declare @ currentNo int
Declare @ rate decimal

Select @ totalNo=count (*) from [LD2017lc] [dbo]. [Computer]

- select @ totalNo
Select @ currentNo=count (*) from [LD2017lc] [dbo] [Computer] where datediff (hh, lastupdinvsvr, getdate ()) & lt;=24
- select @ currentNo

The set @ rate=cast (@ currentNo * 100.0/@ totalNo as int)
Select @ rate
  • Related