The following query returns the members of the database roles.
SELECT DP1.name AS DatabaseRoleName,
The following query returns the members of the database roles.
SELECT DP1.name AS DatabaseRoleName,
CREATE PROCEDURE [util].[SearchAll]
(@strFind AS VARCHAR(MAX))
AS
BEGIN
SET NOCOUNT ON;
--TO FIND STRING IN ALL PROCEDURES
BEGIN
SELECT OBJECT_NAME(OBJECT_ID) SP_Name
,OBJECT_DEFINITION(OBJECT_ID) SP_Definition
FROM sys.procedures
WHERE OBJECT_DEFINITION(OBJECT_ID) LIKE '%'+@strFind+'%'
END
--TO FIND STRING IN ALL VIEWS
BEGIN
SELECT OBJECT_NAME(OBJECT_ID) View_Name
,OBJECT_DEFINITION(OBJECT_ID) View_Definition
FROM sys.views
WHERE OBJECT_DEFINITION(OBJECT_ID) LIKE '%'+@strFind+'%'
END
--TO FIND STRING IN ALL FUNCTION
BEGIN
SELECT ROUTINE_NAME Function_Name
,ROUTINE_DEFINITION Function_definition
FROM INFORMATION_SCHEMA.ROUTINES
WHERE ROUTINE_DEFINITION LIKE '%'+@strFind+'%'
AND ROUTINE_TYPE = 'FUNCTION'
ORDER BY
ROUTINE_NAME
END
--TO FIND STRING IN ALL TABLES OF DATABASE.
BEGIN
SELECT t.name AS Table_Name
,c.name AS COLUMN_NAME
FROM sys.tables AS t
INNER JOIN sys.columns c
ON t.OBJECT_ID = c.OBJECT_ID
WHERE c.name LIKE '%'+@strFind+'%'
ORDER BY
Table_Name
END
END
exec [util].[SearchAll] 'username'
where TABLE_NAME like '%user%'
ORDER by TABLE_NAME
Next example, we want to search all the tables which contains 'username' a column name:
select * from sanjeebDB.INFORMATION_SCHEMA.COLUMNS where COLUMN_NAME like '%username%'
If we need these functions repetitively then we can create a stored procedure and invoke the stored procedure passing keyword as a parameter:
Create PROCEDURE [UTIL].[FIND_TABLE]
(
@pTableName VARCHAR(max)
)
AS
BEGIN
select * from sanjeebDB.INFORMATION_SCHEMA.TABLES
where TABLE_NAME like '%' + @pTableName + '%'
ORDER by TABLE_NAME
END
Assumptions: stored procedures and tables are created under schema dbo. in case different schema, change the below code accordingly.
--Create Login with a strong password
--Run the below code in Master Database
CREATE LOGIN [sanjeebuser] WITH PASSWORD = 'VeryStrongPa55w0rD1!'
--run the below code in your Selected Database, (optional: run in master database as well)
CREATE USER [sanjeebuser]
FOR LOGIN [sanjeebuser]
WITH DEFAULT_SCHEMA = dbo
GO
--Run the below code in your selected Database. please do not run the code in Master database.
CREATE ROLE [dbstoregeprocedureaccess] AUTHORIZATION [dbo]
GRANT EXECUTE,ALTER,DELETE,UPDATE,INSERT ON SCHEMA::dbo TO dbstoregeprocedureaccess;
GRANT CREATE PROCEDURE TO dbstoregeprocedureaccess;
EXEC sp_addrolemember N'db_datareader', N'sanjeebuser'
EXEC sp_addrolemember N'db_datawriter', N'sanjeebuser'
EXEC sp_addrolemember N'dbstoregeprocedureaccess', N'sanjeebuser'
Error:
Access to fetch at 'https://localhost:44340/api/employee' from origin 'https://localhost:44339' has been blocked by CORS policy: Method PUT is not allowed by Access-Control-Allow-Methods in preflight response.
:44340/api/employee:1 Failed to load resource: net::ERR_FAILED
blazor.webassembly.js:1 crit: Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]
Unhandled exception rendering component: TypeError: Failed to fetch
WebAssembly.JSException: TypeError: Failed to fetch
at System.Net.Http.WebAssemblyHttpHandler.doFetch (System.Threading.Tasks.TaskCompletionSource`1[TResult] tcs, System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) <0x2fcb610 + 0x00a30> in <filename unknown>:0
at System.Net.Http.WebAssemblyHttpHandler.SendAsync (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) <0x2f9dd40 + 0x00174> in <filename unknown>:0
at Microsoft.Extensions.Http.Logging.LoggingHttpMessageHandler.SendAsync (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) <0x2f98030 + 0x00160> in <filename unknown>:0
at Microsoft.Extensions.Http.Logging.LoggingScopeHttpMessageHandler.SendAsync (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) <0x2f71090 + 0x00182> in <filename unknown>:0
at System.Net.Http.HttpClient.FinishSendAsyncBuffered (System.Threading.Tasks.Task`1[TResult] sendTask, System.Net.Http.HttpRequestMessage request, System.Threading.CancellationTokenSource cts, System.Boolean disposeCts) <0x3394518 + 0x00278> in <filename unknown>:0
at sanjeebblazorapp.App.Services.EmployeeDataService.UpdateEmployee (sanjeebblazorapp.Shared.Employee employee) [0x00051] in C:\Users\sanje\source\repos\sanjeebko\sanjeebtutorial-blazor\sanjeebblazorapp.App\sanjeebblazorapp.App\Services\EmployeeDataService.cs:42
at sanjeebblazorapp.App.Pages.EmployeeEdit.HandleValidSubmit () [0x001b0] in C:\Users\sanje\source\repos\sanjeebko\sanjeebtutorial-blazor\sanjeebblazorapp.App\sanjeebblazorapp.App\Pages\EmployeeEdit.cs:81
at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion (System.Threading.Tasks.Task task) <0x3395450 + 0x000da> in <filename unknown>:0
at Microsoft.AspNetCore.Components.Forms.EditForm.HandleSubmitAsync () <0x3307b00 + 0x00218> in <filename unknown>:0
at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion (System.Threading.Tasks.Task task) <0x3395450 + 0x000da> in <filename unknown>:0
at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask (System.Threading.Tasks.Task taskToHandle) <0x2fb1590 + 0x000b6> in <filename unknown>:0
Solution:
TO enable cors in .net core web API, cors policy need to be added in the services. Below code in blue color needs to be added in the Startup.cs file
public void ConfigureServices(IServiceCollection services)
{
services.AddDbContext<AppDbContext>(options =>
options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
services.AddCors(options =>
{
options.AddPolicy("Open", builder => builder.AllowAnyOrigin().AllowAnyHeader().WithMethods("PUT","DELETE","GET"));
});
services.AddControllers();
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseHttpsRedirection();
app.UseRouting();
app.UseAuthorization();
app.UseCors("Open");
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
}
Steps1 - Login to the azure account with right account with azure AD access.
Step 2 - Open CloudShell by clicking the icon on the top right corner.
Step 3 - You'll need to associate CLI session with a Storage account. So follow the instruction and connect with the storage account.Step 4 - Select the PowerShell in the dropdown window
You'll see something like this screenshot:
PS /home/sanjeeb> Connect-AzureAd
Step 6 - type the below code (change the group name as your need):
PS /home/sanjeeb>New-AzureADGroup -Description "siteadmingroup" -DisplayName "siteadmingroup" -MailEnabled $false -SecurityEnabled $true -MailNickName "siteadmingroup"
On success, you'll see the object id like below:
ObjectId DisplayName Description
-------- ----------- -----------
daf23147-8123-dc23-bsb8-d2d2a5224271 siteadmingroup siteadmingroup
Open the powershell in the azure. (Select the correct subscription and create storage location for powershell or select an existing storage account)
Run the below query with correct value inside double quote:
Set-AzDataFactoryV2 -ResourceGroupName "MYResourceGroup" -Name "mydatafactory" -Location "UK South"
Press enter, and you'll be prompted to confirm. Type Y and press Enter.
You should see output like below:
Confirm
A data factory with the name mydatafactory in the resource group MYResourceGroup exists.
Continuing execution may overwrite the existing one.
Are you sure you want to continue?
[Y] Yes [N] No [S] Suspend [?] Help (default is "Y"): Y
DataFactoryName : mydatafactory
DataFactoryId : /subscriptions/e01105ad-822a-447a-2dd0-43124d16223l/resourceGroups/MYResourceGroup/providers/Microsoft.DataFactory/factories/mydatafactory
ResourceGroupName : MYResourceGroup
Location : uksouth
Tags : {}
Identity : Microsoft.Azure.Management.DataFactory.Models.FactoryIdentity
ProvisioningState : Succeeded
RepoConfiguration :
GlobalParameters :
For detail information read: Managed identity for Data Factory - Azure Data Factory | Microsoft Docs
Done!
Create a batch file (.bat) and paste the below code:
@echo off
set DAYS=7
robocopy \\192.168.0.30\sanjeebapp\data\in E:\sanjeebapp\data\in\ /mov /maxage:%DAYS%
exit /b
Note: Change the source folder and destination folder as needed. /mov deletes the file from the source location . /maxage ignores the file which is older than DAYS. In this example, the files older than 7 days are not copied.
Remove /mov from the script if you do not want to delete files in the source folder.
Now add a new agent job to Build SSIS. Click the + icon.
for example, the login name is 'mysqluserlogin'
1) Enable the disabled login:
ALTER LOGIN mysqluserlogin ENABLE;
2) Change the login password:
ALTER LOGIN mysqluserlogin WITH PASSWORD = 'thisismynewpassword*&£1';
3) Change the login name:
ALTER LOGIN mysqluserlogin WITH NAME = mysqlusernewlogin;
Scenario: I have an NVMe disk with an ext4 partition that was previously used as a directory in a Proxmox server. After reinstalling Proxm...