My Tech Scrap
Flipkart.com

Translate

Share |

Friday, 25 April 2025

In Microsoft SQL Server, if you see a user under Database > Security > Users, but not under Server > Security > Logins, it means the database user exists, but its corresponding server-level login is missing.

 

This typically happens when a database is restored on a different server, and the associated login wasn't recreated on the new server.

🔧 Fixing the Issue: Create Login & Map to Existing User

You can't reset a password for a database user directly. Instead, you need to:

✅ Step 1: Create a new login at the server level

Use this T-SQL to create a server-level login that matches the database user:

CREATE LOGIN [UserName] WITH PASSWORD = 'YourNewPassword';

Replace UserName with the name shown under Database > Security > Users.

✅ Step 2: Map the login to the existing user in the database

Now, map the newly created login to the existing user:

USE [YourDatabaseName];
ALTER USER [UserName] WITH LOGIN = [UserName];

Friday, 17 January 2025

Python - Extract emails using regex

Here's a simple python script to extract and format the emails:

Script

import re

input_text = "hj sdsd <jkkl.kll.o.v@blbla.com>; jsdsl lassd <jskdsd.uioo@blbla.com>;"

emails = re.findall(r'<([^>]+)>', input_text)

output = ','.join(f'"{email}"' for email in emails)

print(output)


Output

"jkkl.kll.o.v@blbla.com","jskdsd.uioo@blbla.com"

This script uses a regular expression to find all email addresses enclosed in angle brackets < > and formats them as requested.