How to Share Data Between Stored Procedures
http://www.sommarskog.se/share_data.html
A must read.
AWS, data engineering, sql server, talend, postgres, business intelligence, car diy, photography
SELECT @@spid
Use masterGrant access to the user you just created
sp_addlogin 'test', 'password', 'Northwind'
SELECT sid FROM dbo.sysxlogins WHERE name = 'test'
0xE5EFF2DB1688C246855B013148882E75
Use Northwind
sp_grantdbaccess 'test'
SELECT sid FROM dbo.sysusers WHERE name = 'test'
0xE5EFF2DB1688C246855B013148882E75
Use master
BACKUP DATABASE Northwind
TO DISK = 'C:\Northwind.bak'
RESTORE FILELISTONLY
FROM DISK = 'C:\Users\Zahn\Work\Northwind.bak'
Northwind
Northwind_log
RESTORE DATABASE TestDB
FROM DISK = 'C:\Users\Zahn\Work\Northwind.bak'
WITH
MOVE 'Northwind' TO 'D:\DataMSSQL\Data\northwnd.mdf',
MOVE 'Northwind_log' TO 'D:\DataMSSQL\Data\northwnd.ldf'
Use master
SELECT sid FROM dbo.sysxlogins WHERE name = 'test'
0x39EE98D37EAC2243B7833705EC1C60E3
Use TestDB
SELECT sid FROM dbo.sysusers WHERE name ='test'
0xE5EFF2DB1688C246855B013148882E75
Use TestDB
sp_change_users_login 'report'
test 0xE5EFF2DB1688C246855B013148882E75
Use TestDB
sp_change_users_login 'update_one', 'test', 'test'
SELECT sid FROM dbo.sysusers WHERE name = 'test'
0x39EE98D37EAC2243B7833705EC1C60E3
use master
SELECT sid FROM dbo.sysxlogins WHERE name ='test'
0x39EE98D37EAC2243B7833705EC1C60E3