Tuesday 28 January 2020

SQL Get Multi Values in a Single Column

DECLARE @htmlText AS VARCHAR(MAX) = '<br/>'

SELECT STUFF
(   

(      
SELECT @htmlText + t.UserName
FROM Table t
FOR XML PATH(''), TYPE
)
.value('.[1]','nvarchar(max)'), 1, LEN(@htmlText), '' 
)

Thursday 9 January 2020

Sql Server – Split Column With Delimited String Into Multiple Columns

Method 1: To Split A Column With Delimited String Into Multiple Columns more...

Method 2: SELECT
                       PARSENAME(REPLACE ('John,Doe', ',', '.'), 2) 'First Name',
                       PARSENAME(REPLACE ('John,Doe', ',', '.'), 1) 'Last Name'

Tuesday 7 January 2020

Run Python with T-SQL on SSMS

1. Run the following commands in SSMS:
    sp_configure 'external scripts enabled'
    GO
    sp_configure 'external scripts enabled', 1;
    GO
    RECONFIGURE;
    GO
    sp_configure 'external scripts enabled'
    GO

2. Restart the SQL Server Service

3. Run the following command in SSMS:
    sp_configure 'external scripts enabled'
    GO

4. Test the code:
    EXEC sp_execute_external_script
    @language = N'Python',
    @script = N'print(''Hello Python !!! from T-SQL'')'

More...

Python Clear the Interpreter Console

import os
clear = lambda: os.system('cls')
clear()


Thursday 2 January 2020

SQL Key-Value Paired Join

SELECT * FROM Tabe1 u
JOIN (
(123, 'peter6@gmail.com', 3),
(555, 'jbrown@gmail.com', 4),
(946, 'jdoe12@gmail.com', 1)
) v(EmployeeId, Email, Department)
ON (
v.Email = u.Email
and v.EmployeeId = u.EmployeeId
)


Upgrade Windows 11 Home to Windows 11 Pro

Disable internet connection (Wi-Fi, Internet, etc.) Change the product key using the following Generic product key:                     VK7J...