How to Create Multiple SQL Server Instances on Same Server

When you install SQL Server, the installation creates an instance (DEFAULT OR SQLEXPRESS) of SQL Server. In my case I have created instanace named DEVSQL.

Some times we do need to create multiple instances based on requirements. To create more instances, start the setup again. The following screen appears when setup starts for the SQL Server 2012.

Click “New SQL Server stand-alone installation or add features to an existing installation”, the following screen appears:

Installation Start

As you can see DEVSQL instance already exists, it was created by the first installation, now select “New installation or add shared features”. Then click Next and accept the License Agreement.

Then select features you want to install for the new instance.

After that the installation offer you to specify the name of your new instance (MYTEST was chosen in this example):

Click Next to create the new instance and perform the remaining setup steps.

Now you are done!

 

SQL Server – List all the Constraints by Table or by Column Name

List all Constraints of the Database:

SELECT * FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS
OR
SELECT OBJECT_NAME(object_id) AS ConstraintName,
SCHEMA_NAME(schema_id) AS SchemaName,
type_desc AS ConstraintType
FROM sys.objects
WHERE type_desc LIKE '%CONSTRAINT'

List Constraints  on table column:

 Select SysObjects.[Name] As [Contraint Name] ,Tab.[Name] as [Table Name],Col.[Name] As [Column Name]
From SysObjects Inner Join (Select [Name],[ID] From SysObjects Where XType = 'U') As Tab
On Tab.[ID] = Sysobjects.[Parent_Obj]
Inner Join sysconstraints On sysconstraints.Constid = Sysobjects.[ID]
Inner Join SysColumns Col On Col.[ColID] = sysconstraints.[ColID] And Col.[ID] = Tab.[ID]
WHERE Tab.[Name] ='Employee' AND Col.[Name]='DOB'
order by Col.[Name]

how to remove helper warnings at visual studio mvc view page

While working on MVC project we can get warnings in the MVC view/ partial view / layout page.

The name ‘ViewBag’ does not exist in the current context

‘System.Web.WebPages.Html.HtmlHelper’ does not contain a definition for ‘ActionLink’ …

‘System.Web.WebPages.Html.HtmlHelper’ does not contain a definition for ‘AntiForgeryToken’ …

These are due to wrong version in the config file. To fix this we need to update the version of the few things and reopen the project.

Here are few things which I have updated:

<add key="webpages:Version" value="2.0.0.0" />
<add key="webpages:Version" value="3.0.0.0" />
<dependentAssembly>
  <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
  <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
<dependentAssembly>
  <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
  <bindingRedirect oldVersion="1.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
<dependentAssembly>
  <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
  <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
<dependentAssembly>
  <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
  <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
  <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
  <bindingRedirect oldVersion="1.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
</dependentAssembly>
<dependentAssembly>
  <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
  <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
 

 

JSON date to Date object – javascript

While working with web services or API with json return, we will get date values in different format, we can’t use this as is where required.

To convert to date object we need to extract integer value and then pass to Date object, below example shows how to get valid date object.

[javascript]
var json = “/Date(-1827639000000)/”
var mytime = new Date(parseInt(json.replace(“/Date(“, “”).replace(“)/”,””), 10));
alert(mytime);
alert(mytime.toUTCString());

[/javascript]

Debugging VS2013/VS2015 Websites Using 64-bit IIS Express

If you are working on ASP.NET MVC web sites in Visual Studio 2013 (VS2013) or 2015 (VS2015), and want to debug 64bit application, you need to do following changes in Visual Studio.

f you don?t do this, you will likely get a message similar to:

?Could not load file or assembly or one of its dependencies. An attempt was made to load a program with an incorrect format.?

For Visual Studio 2013 and Visual Studio 2015:

Tools
  -> Options
   -> Projects and Solutions
    -> Web Projects
     -> Check "Use the 64 bit version of IIS Express for web sites and projects"`