Wednesday, May 22, 2019

How do I add the source code to a TFS project

"Add the files to Source Control".

Do this by:

Opening the Solution in Visual Studio, then right-clicking on the solution and selecting "Add Solution to Source Control" - This will miss any files that are not part of the solution.


Open Source Explorer, navigate to the mapped folder, and right-click in the empty space and select "Add files"


Tuesday, May 21, 2019

How do I connect to SQL Server 2012 through ASP.NET Core 2.0

Define your connection in the configuration file or context
 e.g
var connection = @"Server=.;Database=Testing;Trusted_Connection=True;ConnectRetryCount=0";

Go to your startup file and add the correct context
 e.g
services.AddDbContext<ExampleContext>(options => options.UseSqlServer(connection)); }
or
var connection = Configuration.GetConnectionString("DatabaseConnection");
            services.AddDbContext<DatabaseContext>(options => options.UseSqlServer(connection));

Monday, May 20, 2019

Remove all Triggers

 -- drop all user defined triggers
Declare @trgName varchar(500)
Declare cur Cursor For Select [name] From sys.objects where type = 'tr'
Open cur
Fetch Next From cur Into @trgName
While @@fetch_status = 0
Begin
 Exec('drop trigger ' + @trgName)
 Fetch Next From cur Into @trgName
End
Close cur
Deallocate cur 

Remove all Views

 -- drop all user defined views
Declare @viewName varchar(500)
Declare cur Cursor For Select [name] From sys.objects where type = 'v'
Open cur
Fetch Next From cur Into @viewName
While @@fetch_status = 0
Begin
 Exec('drop view ' + @viewName)
 Fetch Next From cur Into @viewName
End
Close cur
Deallocate cur 

Remove all User-defined Stored Procedures

 -- drop all user defined stored procedures
Declare @procName varchar(500)
Declare cur Cursor For Select [name] From sys.objects where type = 'p'
Open cur
Fetch Next From cur Into @procName
While @@fetch_status = 0
Begin
 Exec('drop procedure ' + @procName)
 Fetch Next From cur Into @procName
End
Close cur
Deallocate cur 

Sql Server - drop synonyms from specific schema

declare @syn nvarchar(300)
declare @temp1 nvarchar(300)
declare read_cur cursor for select distinct name from sys.synonyms where is_ms_shipped = 0

open read_cur
fetch read_cur into @syn
while @@fetch_status = 0
begin
      --select read_cur into @temp1
      set @temp1='drop synonym '+@syn
      exec sp_executesql @temp1

      fetch read_cur into @syn
end
close read_cur
deallocate read_cur

Monday, May 13, 2019

.NET Core vs ASP.NET Core

.NET Core is a free and open-source managed computer software framework for the Windows, Linux, and macOS operating systems.

ASP.NET Core can target .NET Core or .NET Framework. ASP.NET Core apps targeting .NET Framework aren't cross-platform—they run on Windows only. Generally, ASP.NET Core is made up of .NET Standard libraries. Libraries written with .NET Standard 2.0 run on any .NET platform that implements .NET Standard 2.0.


Thursday, May 2, 2019

How to write a query to ensure email contains @

The underscore character ( _ ) represents any single character.

The percent sign character (%) represents a string of zero or more characters.

SELECT email
FROM YourTable
WHERE email LIKE '%_@__%.__%'