добавьте в текст функции вывод в отдельную таблицу реперных значений, позволяющих понять, что дала очередная итерация и почему потребовалась следующая
TRIM(Phone)
. Именно из-за конечных пробелов и делается " бессмысленная операция".VARCHAR
, нужно CAST(Phone AS VARCHAR)
.DECLARE @Table TABLE ( Phone NVARCHAR(50))
INSERT @Table VALUES
('ghgf+1*2-3YYU '),
(NULL),
(''),
(N'01©23Ӡ')
SELECT Phone, CAST(Phone AS VARCHAR), TRIM(CAST(Phone AS VARCHAR)),
REPLACE (
TRANSLATE( TRIM(CAST(Phone AS VARCHAR)),
REPLACE(
TRANSLATE( TRIM(CAST(Phone AS VARCHAR)), '0123456789', '##########'), '#', ''),
REPLICATE( '#', LEN(
REPLACE(
TRANSLATE( TRIM(CAST(Phone AS VARCHAR)), '0123456789', '##########'), '#', '')))), '#', '')
FROM @Table
USE [master]
GO
CREATE DATABASE [Testus_copy] ON
( FILENAME = N'C:\MSSQL\Testus_copy.mdf' ),
( FILENAME = N'C:\MSSQL\Testus_copy.ldf' )
FOR ATTACH
GO
$Server = '.\SQLEXPRESS'
$InitialCatalog = 'master'
$DatabaseName = 'managementDB'
# Connect to SQL server
$conn = New-Object System.Data.Sqlclient.SqlConnection
$conn.ConnectionString = "Data Source=$Server; Initial Catalog=$InitialCatalog; Integrated Security=True;"
$conn.Open()
# Создание БД
$cmd = $conn.CreateCommand()
$cmd.CommandText = "IF NOT EXISTS (SELECT name FROM master.dbo.sysdatabases WHERE name = '$DatabaseName') CREATE DATABASE [$DatabaseName] COLLATE Cyrillic_General_CI_AS;"
$cmd.ExecuteNonQuery() | Out-Null
# Создание БД
$cmd.CommandText = "USE $DatabaseName; IF NOT EXISTS ( SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'ipaddress' ) CREATE TABLE [dbo].[ipaddress]([ip][varchar](15) NULL UNIQUE) ON [PRIMARY];"
$cmd.ExecuteNonQuery() | Out-Null
$cmd.Dispose();
$conn.Close();
$conn.Dispose();
Windows 11: Не поддерживается.Package properties: Description: Microsoft SQL Server 2014 Installation edition: Standard
diplom
.SELECT Sungero_Core_Recipient.Name AS Addressee,
dev_Kemero1_CityDistricts.Name AS District,
1 AS [Count]
FROM [Sungero_Content_EDoc]
JOIN dev_Kemero1_CityDistricts ON dev_Kemero1_CityDistricts.Id = [Sungero_Content_EDoc].Districtdev_Kemerov_dev
JOIN Sungero_Core_Recipient ON Sungero_Core_Recipient.Id = [Sungero_Content_EDoc].InAddressee_Docflow_Sungero
WHERE [Sungero_Content_EDoc].Name LIKE 'Обращение%'
SELECT Sungero_Core_Recipient.Name AS Addressee,
dev_Kemero1_CityDistricts.Name AS District,
COUNT(*) AS [Count]
FROM [Sungero_Content_EDoc]
JOIN dev_Kemero1_CityDistricts ON dev_Kemero1_CityDistricts.Id = [Sungero_Content_EDoc].Districtdev_Kemerov_dev
JOIN Sungero_Core_Recipient ON Sungero_Core_Recipient.Id = [Sungero_Content_EDoc].InAddressee_Docflow_Sungero
WHERE [Sungero_Content_EDoc].Name LIKE 'Обращение%'
GROUP BY Sungero_Core_Recipient.Name, dev_Kemero1_CityDistricts.Name
SELECT dc.session_id AS [SPID],
dc.client_net_address AS [IP клиента],
sp.hostname AS [Имя PC клиента],
dc.local_net_address AS [IP подключения к серверу],
dc.net_transport AS [Протокол подключения],
dc.local_tcp_port AS [Порт],
sp.[program_name] AS [Имя программы],
sp.loginame
FROM sys.dm_exec_connections dc
INNER JOIN MASTER.sys.sysprocesses sp ON dc.session_id = sp.spid