European Windows 2012 Hosting BLOG

BLOG about Windows 2012 Hosting and SQL 2012 Hosting - Dedicated to European Windows Hosting Customer

SQL Server 2014 Hosting - HostForLIFE.eu :: How to Install SQL Server 2014 on Windows 10?

clock March 31, 2016 19:16 by author Anthony

Windows 10 is an operating system developed by Microsoft. Microsoft user interface 10 is designed specifically to optimize the experience based on the type of device and provided input, provide the right experience on devices teoat and at the right time. Therefore, in this article I will discuss and explain how to install SQL Server 2014 on Windows 10 operating systems.

There are several ways that can be used to install SQL Server 2014. Through the command prompt, server core, and others. But in this discussion, I will explain the easiest way, which is through SQL Server 2014 Setup wizard.

  • The first thing to do is you need to download SQL Server 2014 from Microsoft. You are free to choose for x64 or x86 according to your operating system.
  • Then double click on the .exe file has been downloaded, or to extract it. Then click the setup.exe file from folder.
  • After that it will open the SQL Server Installation Center. Select Installation, then select New SQL Server stand-alone installation or add features to an existing installation
  • After that, please check the I accept the license terms and click Next.
  • Then let SQL Server 2014 installed.
  • image

  • Then it will appear in the SQL Server 2014 Setup, Feature Selection. Select the checkboxes as shown below and click the Next button.
  • image

  • Next will appear on the SQL Server 2014 Setup, Configuration Instance. You can fill in the Name Instance in accordance with the needs and desires. In this tutorial I will be using SQLExpress. Once completed, please click the Next button.
  • image

  • Then you will see Server Configuration. selective startup type for SQL Browser as Automatic. Note that this is optional and click the Next button.
  • Then on the Database Engine Configuration, the Server Configuration tab, please select Mixed Mode (SQL Server authentication and Windows authentication). Then enter the password as well. You can also add users by clicking Add Current User. Then select Next.
  • image

  • After that you will see the installation of SQL Server 2014 when the installation has been completed.
  • Then you can click on the Start menu windows, you will find SQL Server 2014 has been installed. Please click on the SQL Server 2014 Management Studio. Then enter the server name matches the name that you created. In this tutorial I will put SQLEXPRESS on the server name. After that please click the Connect button.
  •  

HostForLIFE.eu SQL 2014 Hosting
HostForLIFE.eu revolutionized hosting with Plesk Control Panel, a Web-based interface that provides customers with 24x7 access to their server and site configuration tools. Plesk completes requests in seconds. It is included free with each hosting account. Renowned for its comprehensive functionality - beyond other hosting control panels - and ease of use, Plesk Control Panel is available only to HostForLIFE's customers. They
offer a highly redundant, carrier-class architecture, designed around the needs of shared hosting customers.



AngularJS Hosting - HostForLIFE.eu :: How to Datatable Binding Using AngularJS?

clock March 30, 2016 00:05 by author Peter

Today I want to show you how to Datatable Binding Using AngularJS. Now write the following code:
<html xmlns="http://www.w3.org/1999/xhtml"> 

  <head> 
      <title>Datatable Records Using AngularJS</title> 
      <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.9/angular.min.js"></script> 
      <script src="http://ui-grid.info/release/ui-grid-unstable.js"></script> 
      <link rel="stylesheet" href="http://ui-grid.info/release/ui-grid-unstable.css" type="text/css"> 
      <script type="text/javascript"> 
      debugger; 
      var myApp = angular.module('sampleapp', ['ui.grid', 'ui.grid.selection', 'ui.grid.exporter']); 
      myApp.controller("appcontroller", function ($scope, $http) 
      { 
          $scope.gridOptions = { 
              data: 'BindDataTableusingJSON', 
              columnDefs: [ 
              { 
                  field: 'Application_Number' 
              }, 
              { 
                  field: 'Candidate_Name' 
              }, 
              { 
                  field: 'Category' 
              }, 
              { 
                  field: 'Fathers_Name' 
              }, 
              { 
                  field: 'Date' 
              }, 
              { 
                  field: 'Address' 
              }] 
          }; 
          $scope.BindDataTableusingJSON = { 
              "data": [] 
          }; 
          $http.post('try2.aspx/SaveUser', 
              { 
                  data: 
                  {} 
              }) 
              // $http.get('try2.aspx/SaveUser') 
              .success(function (data) 
              { 
                  debugger; 
                  // var data = jQuery.parseJSON(data.d.toString()); 
                  var d = JSON.parse(data.d); 
                  $scope.BindDataTableusingJSON = d; 
              }); 
      }).config(function ($httpProvider) 
      { 
          $httpProvider.defaults.headers.post = {}; 
          $httpProvider.defaults.headers.post["Content-Type"] = "application/json; charset=utf-8"; 
      }); 
      </script> 
      <style type="text/css"> 
      .grid { 
          width: 800px; 
          height: 400px; 
      } 
       
      .nodatatxt { 
          position: absolute; 
          top: 80px; 
          opacity: 0.25; 
          font-size: 1.5em; 
          width: 100%; 
          text-align: center; 
          z-index: 1000; 
      } 
      </style> 
  </head> 

  <body> 
      <form id="form1" runat="server"> 
          <div ng-app="sampleapp" ng-controller="appcontroller"> 
              <br /> 
              <br /> 
              <div ui-grid="gridOptions" ui-grid-selection ui-grid-exporter class="grid"> 
                  <div class="nodatatxt" ng-if="BindDataTableusingJSON.data.length==0"> No Records Found</div> 
              </div> 
          </div> 
      </form> 
  </body> 

</html> 

Code-behind

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Web; 
using System.Web.UI; 
using System.Web.UI.WebControls; 
using System.Data; 
using System.Web.Script.Serialization; 
using System.Web.Services; 
using System.Web.Script.Services; 
public partial class Services_t_try2: System.Web.UI.Page 

  protected void Page_Load(object sender, EventArgs e) 
  {} 
  [WebMethod] 
  [ScriptMethod] 
  public static string SaveUser() 
  { 
      DataSet ds = YourFunctionWhichReturnsDataset(); 
      DataTable dt = ds.Tables[0]; 
      ds.Tables[0].Columns[4].ColumnName = ds.Tables[0].Columns[4].ColumnName.Replace("Date Of Birth", "Date"); 
      return DataTableToJSONWithJavaScriptSerializer(ds.Tables[0]); 
  } 
  public static string DataTableToJSONWithJavaScriptSerializer(DataTable table) 
  { 
      JavaScriptSerializer jsSerializer = new JavaScriptSerializer(); 
      List < Dictionary < string, object >> parentRow = new List < Dictionary < string, object >> (); 
      Dictionary < string, object > childRow; 
      foreach(DataRow row in table.Rows) 
      { 
          childRow = new Dictionary < string, object > (); 
          foreach(DataColumn col in table.Columns) 
          { 
              childRow.Add(col.ColumnName, row[col]); 
          } 
          parentRow.Add(childRow); 
      } 
      return jsSerializer.Serialize(parentRow); 
  } 

 

HostForLIFE.eu AngularJS Hosting

HostForLIFE.eu is European Windows Hosting Provider which focuses on Windows Platform only. We deliver on-demand hosting solutions including Shared hosting, Reseller Hosting, Cloud Hosting, Dedicated Servers, and IT as a Service for companies of all sizes.



SQL Server Hosting - HostForLIFE.eu :: How to Use Visual Studio 2010 as a SQL Server?

clock March 29, 2016 23:29 by author Anthony

In this article I will discuss about how to use Visual Studio 2010 as a SQL Server database management studio. If you want to create applications using the .NET Framework you certainly will need Microsoft Visual Studio as IDE to build your application. If you have installed SQL Server course you will need a SQL Server Management Studio as your medium to process and manipulate data.


What if you've already installed Microsoft Visual Studio but when installing Microsoft SQL Server does not install the SQL Server Management Studio?

Of course you can not query your data right, and you can only pass the command prompt. But with Microsoft Visual SQL Management Studio as the media, you can process the data in the Microsoft Visual Studio IDE

  1. Run Microsoft Visual Studio, and then open Server Explorer listed on the menu view. After that will appear Data Connection and Server.
  1. Add a data connection by clicking the right mouse button and select Add Connection. Then see the database connection will appear.
  2. Enter your name server as the instance name on your SQL Server, log into SQL by using the username and password to get access, or by using Windows authentication. Then select the database you want to use and then press the Test Connection button, and make sure that the connection to the database successfully.

  3. If the Data Connection has been filled with database structure view you have, and then query the data from the database table and by right-clicking on the Data Connection that you created and select New Query.

  4. It will display the Query Window. Then select the table you want to create the query. But not only the table that can be in the query, Views, Function and Synonims you can also query the right to suit your needs.

  5. Once you select a table, the query functioned in accordance with the display data or you can write a query that you want on the bottom. To be able to execute the query, you can click the Execute button or by pressing the F5 key

HostForLIFE.eu SQL Server Hosting

European best, cheap and reliable ASP.NET hosting with instant activation. HostForLIFE.eu is #1 Recommended Windows and ASP.NET hosting in European Continent. With 99.99% Uptime Guaranteed of Relibility, Stability and Performace. HostForLIFE.eu security team is constantly monitoring the entire network for unusual behaviour. We deliver hosting solution including Shared hosting, Cloud hosting, Reseller hosting, Dedicated Servers, and IT as Service for companies of all size.



SQL Server 2014 Hosting - HostForLIFE.eu :: How to Remove Duplicate Data From String on SQL Server?

clock March 15, 2016 21:10 by author Peter

In this tutorial, let me show you how to remove data from string in which data are separated by delimiter. An identifier that complies with all the rules for the format of identifiers can be used with or without delimiters. An identifier that does not comply with the rules for the format of regular identifiers must always be delimited.

Delimited identifiers are used in these situations:

  • When reserved words are used for object names or portions of object names.

    It is recommended that reserved keywords not be used as object names. Databases upgraded from earlier versions of Microsoft® SQL Server™ may contain identifiers that include words not reserved in the earlier version, but are reserved words for SQL Server 2000. You can refer to the object using delimited identifiers until the name can be changed.

  • When using characters not listed as qualified identifiers.

    SQL Server allows any character in the current code page to be used in a delimited identifier; however, indiscriminate use of special characters in an object name may make SQL statements and scripts difficult to read and maintain.

You can use the following code:   

CREATE FUNCTION [dbo].[DistinctList] 
    ( 
    @List VARCHAR(MAX), 
    @Delim CHAR 
    ) 
    RETURNS 
    VARCHAR(MAX) 
    AS 
    BEGIN 
    DECLARE @Return_List [varchar](max); 
    DECLARE @Temp_Str [varchar](max); 
    DECLARE @Char_index int; 
    SET @List=@List+@Delim; 
    SET @Return_List=''; 
    SET @Char_index=CHARINDEX(@Delim,@List,1); 
    WHILE @Char_index>0 
    BEGIN 
    SET @Temp_Str=SUBSTRING(@List,1,@Char_index-1); 
    SET @Return_List=@Return_List+@Temp_Str+@Delim; 
    SET @List=REPLACE(@List,@Temp_Str+@Delim,''); 
    SET @Char_index=CHARINDEX(@Delim,@List,1); 
    END 
    Return SUBSTRING(@Return_List,1 ,LEN(@Return_List)-1); 
    END  


In this function first parameter take the string  and second parameter the delimiter ,on the behalf of this delimiter we split the string and remove the duplicate data.
    DECLARE @String [varchar](max); 
    SET @String='10,11,12,10,11'; 
    SELECT dbo.DistinctList(@String,',') AS List; 


And here is the output:
10,11,12

HostForLIFE.eu SQL Server 2014 Hosting
HostForLIFE.eu is European Windows Hosting Provider which focuses on Windows Platform only. We deliver on-demand hosting solutions including Shared hosting, Reseller Hosting, Cloud Hosting, Dedicated Servers, and IT as a Service for companies of all sizes.



SQL Server 2014 Hosting - HostForLIFE.eu :: Make an Index on #temp tables on SQL Server

clock March 8, 2016 21:12 by author Peter

Today let me explain you about how to make an Index on #temp tables. #Temp tables are much like SQL tables that are defined and stored in TempDB. Difference between them and a permanent table is they are not allowed to have foreign keys.


One of the feature of temp table (#temp) is that we can add a clustered or non clustered index. Also, #temp tables allow for the auto-generated columns (fields) to be created. This can help the optimizer when determining the number of records. Below is an example of creating both a clustered and non-clustered index on a temp table.
-- creating temp table - #employees
CREATE TABLE #Employees 

ID INT IDENTITY(1,1), 
EmployeeID INT, 
EmployeeName VARCHAR(50) 


INSERT INTO #Employees 

EmployeeID, 
EmployeeName 

SELECT 
EmployeeID = e.EmployeeID 
,EmployeeName = e.EmployeeName 
FROM dbo.Employees e 
 
-- creating clustered index 
CREATE CLUSTERED INDEX IDX_C_Employees_EmployeeID ON #Employees(EmployeeID)
 
-- creating non-clustured index 
CREATE INDEX IDX_Users_UserName ON #Employees(EmployeeName) 

 

HostForLIFE.eu SQL Server 2014 Hosting
HostForLIFE.eu is European Windows Hosting Provider which focuses on Windows Platform only. We deliver on-demand hosting solutions including Shared hosting, Reseller Hosting, Cloud Hosting, Dedicated Servers, and IT as a Service for companies of all sizes.



AngularJS Hosting - HostForLIFE.eu :: How to create Strong Password for AngularJS?

clock March 3, 2016 21:33 by author Peter

This code snippet helps us in choosing a strong password for AngularJS UI pages. All of us have seen , for choosing a password we need combination of special characters, Capital letter , small letters, digits etc to make it strong.

Write the following code:

<!DOCTYPE html>  
<html>  
<head>  
<title>Strong Password for Angular UI Pages</title>  

<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.8/angular.min.js"></script>    
<script>  
var app = angular.module("myApp", []);  
app.controller("myCtrl", function ($scope) {  

    var strongRegularExp = new RegExp("^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[!@#\$%\^&\*])(?=.{8,})");  

    var mediumRegularExp = new RegExp("^(((?=.*[a-z])(?=.*[A-Z]))|((?=.*[a-z])(?=.*[0-9]))|((?=.*[A-Z])(?=.*[0-9])))(?=.{6,})");  

    $scope.checkpwdStrength = {  
        "width": "150px",  
        "height": "25px",  
        "float": "right"  
    };  

    $scope.validationInputPwdText = function (value) {  
        if (strongRegularExp.test(value)) {  
            $scope.checkpwdStrength["background-color"] = "green";  
            $scope.userPasswordstrength = 'You have a Very Strong Password now';  
        } else if (mediumRegularExp.test(value)) {  
            $scope.checkpwdStrength["background-color"] = "orange";  
            $scope.userPasswordstrength = 'Strong password, Please give a very strong password';  
        } else {  
            $scope.checkpwdStrength["background-color"] = "red";  
            $scope.userPasswordstrength = 'Weak Password , Please give a strong password';  
        }  
    };  

});  
</script>  
</head>  
<body ng-app="myApp">  
<div ng-controller="myCtrl" style="border:5px solid gray; width:800px;">  
<div>  
    <h3>Strong Password for Angular UI Pages </h3>  
</div>  
<div style="padding-left:25px;">  
    <div ng-style="checkpwdStrength"></div>  
    <input type="password" ng-model="userPassword" ng-change="validationInputPwdText(userPassword)" class="class1" />  
    <b> {{userPasswordstrength}}</b>  
</div>  
<br />  
<br />  
<br />  
</div>  
</body>  
</html>  

HostForLIFE.eu AngularJS Hosting

HostForLIFE.eu is European Windows Hosting Provider which focuses on Windows Platform only. We deliver on-demand hosting solutions including Shared hosting, Reseller Hosting, Cloud Hosting, Dedicated Servers, and IT as a Service for companies of all sizes.



How To Collect Performance Metrics From SQL Server Query Analyzer?

clock March 1, 2016 20:37 by author Peter

In this topic, I will show you how to collect value of performance counters from query analyzer. Microsoft® SQL Server SQL Query Analyzer is a graphical tool that allows you to:

  • Create queries and other SQL scripts and execute them against SQL Server databases. (Query window)
  • Quickly create commonly used database objects from predefined scripts. (Templates)
  • Quickly copy existing database objects. (Object Browser scripting feature)
  • Execute stored procedures without knowing the parameters. (Object Browser procedure execution feature)
  • Debug stored procedures. (T-SQL Debugger)
  • Debug query performance problems. (Show Execution Plan, Show Server Trace, Show Client Statistics, Index Tuning Wizard)
  • Locate objects within databases (object search feature), or view and work with objects. (Object Browser)
  • Quickly insert, update, or delete rows in a table. (Open Table window)
  • Create keyboard shortcuts for frequently used queries. (custom query shortcuts feature)
  • Add frequently used commands to the Tools menu. (customized Tools menu feature)

The following code is demo query to do same. You can create collect any counter vale for instant. Now write the code:

/*************************************************/
USE Master
GO
Create Table Perfmon (Object_name Varchar (200),
Counter_name varchar (300) , Instance_name varchar (100),
cntr_value bigint, cntr_type bigint , date varchar (20))
GO
Insert into Perfmon
SELECT object_name , counter_name , instance_name , cntr_value, cntr_type
, convert (varchar (20),getdate () , 120) as date
FROM sys.dm_os_performance_counters
WHERE OBJECT_NAME in
(
'MSSQL$Servername:Databases' ,
'MSSQL$Servername:General Statistics',
'MSSQL$Servername:Buffer Manager' ,
'MSSQL$Servername:Locks'
)
AND counter_name in
(
'Transactions/sec' ,'User Connections','Page life expectancy',
'Buffer cache hit ratio', 'Buffer cache hit ratio base' ,
'Free pages','Total pages','Target pages','Lock Wait Time (ms)'
)
Select @@servername
GO
Select *, case
when cntr_type  = 65792  Then 'instant_value'
when cntr_type = 272696576 Then 'Incremental'
When cntr_type = 1073939712 Then 'Instant fraction'
When cntr_type = 537003264 Then 'Use this with Base value'
else 'null' end 
from Master.dbo.perfmon
/*************************************************/

HostForLIFE.eu SQL Server 2014 Hosting
HostForLIFE.eu is European Windows Hosting Provider which focuses on Windows Platform only. We deliver on-demand hosting solutions including Shared hosting, Reseller Hosting, Cloud Hosting, Dedicated Servers, and IT as a Service for companies of all sizes.



SQL Server 2014 Hosting - HostForLIFE.eu :: String comparison and Collation in SQL Server

clock February 23, 2016 19:39 by author Peter

You probably already know that string comparison is dependent on the collation. but sometimes this dependency is slightly strange. I have installed an SQL Server with LATIN1_GENERAL_CI_AS as default collation (like is also the default setting during installation). Some weeks ago I came across a specific behavior in combination of this collation and the german language.

German is a stunning language! really. You may know that we have a tendency to Germans have some special vowels (the “Umlaut”: ä, ö, and ü) and also that extra ß which is often (but not always) simply interchangeable with “ss”. look at this query that uses the default collation for comparison:
select case
 when 'ss' collate latin1_general_ci_as
     = 'ß' collate latin1_general_ci_as
      then 'Yes'
 else 'No'
end [ss=ß?]

Considering that LATIN1_GENERAL_CI_AS is the default collation, the query above is identical to the following query:
select case
 when 'ss' = 'ß' then 'Yes'
 else 'No'
end [ss=ß?]

In both cases the result is Yes, so “ß” is considered as to be identical to “ss” when using the LATIN1_GENERAL_CI_AS collation. Now it's time to look at this query:

select case
 when 'ä' = 'ae' then 'Yes'
 else 'No'
end [ä=ae?]

This time the answer is no which is somewhat surprising, since one could consider the overall behavior inconsistent. In German, “ä” and “ae” (and also “ö” and “oe” in addition as “ü” and “ue”) are just as interchangeable as “ß” and “ss”. When this happened to me, I started browsing books online. There’s a hint, where you're advised setting the default collation to LATIN1_GENERAL_BIN for new installations. I didn’t know this so far, but ok: let’s retry our experiment:

select case
 when 'ss' collate latin1_general_bin
     = 'ß' collate latin1_general_bin
      then 'Yes'
 else 'No'
end [ss=ß?]

Now the answer is no. but considering the fact that most newer installations use LATIN1_GENERAL_CI_AS, simply because that’s the default during installation, I can’t just change the collation to LATIN1_GENERAL_BIN, since this will certainly produce other problems with queries spanning multiple databases with totally different collations. Not taking into account that changing the collation for an existing server and all of its databases/columns is a cumbersome and also very risky task on its own.

 

HostForLIFE.eu SQL Server 2014 Hosting
HostForLIFE.eu is European Windows Hosting Provider which focuses on Windows Platform only. We deliver on-demand hosting solutions including Shared hosting, Reseller Hosting, Cloud Hosting, Dedicated Servers, and IT as a Service for companies of all sizes.



SQL Server 2014 Hosting - HostForLIFE.eu :: How to Return Value in SQL Server from EXEC Function ?

clock February 16, 2016 20:15 by author Peter

In this tutorial, I will show you how to Return Value in SQL Server  from EXEC Function. If you specify the OUTPUT keyword for a parameter in the procedure definition, the procedure can return the current value of the parameter to the calling program when the procedure exits. The following Stored Procedure is used which returns an Integer value 1 if the StudentId exists and 0 if the StudentId does not exists.

CREATE PROCEDURE CheckStudentId 
@StudentId INT 
AS 
BEGIN 
SET NOCOUNT ON; 
DECLARE @Exists INT 
IF EXISTS(SELECT StudentId FROM Students WHERE StudentId = @StudentId) 
BEGIN 
SET @Exists = 1 
END 
ELSE 
BEGIN 
SET @Exists = 0 
END 
RETURN @Exists 
END 

Returned value from EXEC function:
The returned integer value from the Stored Procedure, you need to make use of an Integer variable and use along with the EXEC command while executing the Stored Procedure.

    DECLARE @ReturnValue INT 
    EXEC @ReturnValue = < Store Procedure Name > < Parameters > Select @ReturnValue 
    Example: DECLARE @ReturnValue INT 
    EXEC @ReturnValue = CheckStudentId 34 
    SELECT @ReturnValue 

If There are valid StudentId then Output will be : 1

 

HostForLIFE.eu SQL Server 2014 Hosting
HostForLIFE.eu is European Windows Hosting Provider which focuses on Windows Platform only. We deliver on-demand hosting solutions including Shared hosting, Reseller Hosting, Cloud Hosting, Dedicated Servers, and IT as a Service for companies of all sizes.



SQL Server 2014 Hosting - HostForLIFE.eu :: How to Empty and Deleter All SQL Database?

clock February 9, 2016 23:06 by author Peter

Today, let me show you how to empty and delete all SQL Database. Now write the following code snippet for Clear Blank SQL Database:

    DECLARE @name VARCHAR(128) 

    DECLARE @SQL VARCHAR(254) 

    SELECT @name = (SELECT TOP 1 [name] FROM sysobjects WHERE [type] = 'P' AND category = 0 ORDER BY [name]) 

    WHILE @name is not null 

    BEGIN 

        SELECT @SQL = 'DROP PROCEDURE [dbo].[' + RTRIM(@name) +']' 

        EXEC (@SQL) 

        PRINT 'Dropped Procedure: ' + @name 

        SELECT @name = (SELECT TOP 1 [name] FROM sysobjects WHERE [type] = 'P' AND category = 0 AND [name] > @name ORDER BY [name]) 

    END 

    GO 

    /* Drop all views */ 

    DECLARE @name VARCHAR(128) 

    DECLARE @SQL VARCHAR(254)

 

    SELECT @name = (SELECT TOP 1 [name] FROM sysobjects WHERE [type] = 'V' AND category = 0 ORDER BY [name]) 

    WHILE @name IS NOT NULL 

    BEGIN 

        SELECT @SQL = 'DROP VIEW [dbo].[' + RTRIM(@name) +']' 

        EXEC (@SQL) 

        PRINT 'Dropped View: ' + @name 

        SELECT @name = (SELECT TOP 1 [name] FROM sysobjects WHERE [type] = 'V' AND category = 0 AND [name] > @name ORDER BY [name]) 

    END 

    GO 

    /* Drop all functions */ 

    DECLARE @name VARCHAR(128)  

    DECLARE @SQL VARCHAR(254)     

    SELECT @name = (SELECT TOP 1 [name] FROM sysobjects WHERE [type] IN (N'FN', N'IF', N'TF', N'FS', N'FT') AND category = 0 ORDER BY [name])      

    WHILE @name IS NOT NULL 

    BEGIN 

        SELECT @SQL = 'DROP FUNCTION [dbo].[' + RTRIM(@name) +']' 

        EXEC (@SQL) 

        PRINT 'Dropped Function: ' + @name 

        SELECT @name = (SELECT TOP 1 [name] FROM sysobjects WHERE [type] IN (N'FN', N'IF', N'TF', N'FS', N'FT') AND category = 0 AND [name] > @name ORDER BY [name]) 

    END 

    GO      

    /* Drop all Foreign Key constraints */ 

    DECLARE @name VARCHAR(128) 

    DECLARE @constraint VARCHAR(254) 

    DECLARE @SQL VARCHAR(254)      

    SELECT @name = (SELECT TOP 1 TABLE_NAME FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE constraint_catalog=DB_NAME() AND CONSTRAINT_TYPE = 'FOREIGN KEY' ORDER BY TABLE_NAME)      

    WHILE @name is not null 

    BEGIN 

        SELECT @constraint = (SELECT TOP 1 CONSTRAINT_NAME FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE constraint_catalog=DB_NAME() AND CONSTRAINT_TYPE = 'FOREIGN KEY' AND TABLE_NAME = @name ORDER BY CONSTRAINT_NAME) 

        WHILE @constraint IS NOT NULL 

        BEGIN 

            SELECT @SQL = 'ALTER TABLE [dbo].[' + RTRIM(@name) +'] DROP CONSTRAINT [' + RTRIM(@constraint) +']' 

            EXEC (@SQL) 

            PRINT 'Dropped FK Constraint: ' + @constraint + ' on ' + @name 

            SELECT @constraint = (SELECT TOP 1 CONSTRAINT_NAME FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE constraint_catalog=DB_NAME() AND CONSTRAINT_TYPE = 'FOREIGN KEY' AND CONSTRAINT_NAME <> @constraint AND TABLE_NAME = @name ORDER BY CONSTRAINT_NAME) 

        END 

    SELECT @name = (SELECT TOP 1 TABLE_NAME FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE constraint_catalog=DB_NAME() AND CONSTRAINT_TYPE = 'FOREIGN KEY' ORDER BY TABLE_NAME) 

    END 

    GO      

    /* Drop all Primary Key constraints */ 

    DECLARE @name VARCHAR(128) 

    DECLARE @constraint VARCHAR(254) 

    DECLARE @SQL VARCHAR(254)      

    SELECT @name = (SELECT TOP 1 TABLE_NAME FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE constraint_catalog=DB_NAME() AND CONSTRAINT_TYPE = 'PRIMARY KEY' ORDER BY TABLE_NAME)      

    WHILE @name IS NOT NULL 

    BEGIN 

        SELECT @constraint = (SELECT TOP 1 CONSTRAINT_NAME FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE constraint_catalog=DB_NAME() AND CONSTRAINT_TYPE = 'PRIMARY KEY' AND TABLE_NAME = @name ORDER BY CONSTRAINT_NAME) 

        WHILE @constraint is not null 

        BEGIN 

            SELECT @SQL = 'ALTER TABLE [dbo].[' + RTRIM(@name) +'] DROP CONSTRAINT [' + RTRIM(@constraint)+']' 

            EXEC (@SQL) 

            PRINT 'Dropped PK Constraint: ' + @constraint + ' on ' + @name 

            SELECT @constraint = (SELECT TOP 1 CONSTRAINT_NAME FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE constraint_catalog=DB_NAME() AND CONSTRAINT_TYPE = 'PRIMARY KEY' AND CONSTRAINT_NAME <> @constraint AND TABLE_NAME = @name ORDER BY CONSTRAINT_NAME) 

        END 

    SELECT @name = (SELECT TOP 1 TABLE_NAME FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE constraint_catalog=DB_NAME() AND CONSTRAINT_TYPE = 'PRIMARY KEY' ORDER BY TABLE_NAME) 

    END 

    GO      

    /* Drop all tables */ 

    DECLARE @name VARCHAR(128) 

    DECLARE @SQL VARCHAR(254)      

    SELECT @name = (SELECT TOP 1 [name] FROM sysobjects WHERE [type] = 'U' AND category = 0 ORDER BY [name])      

    WHILE @name IS NOT NULL 

    BEGIN 

        SELECT @SQL = 'DROP TABLE [dbo].[' + RTRIM(@name) +']' 

        EXEC (@SQL) 

        PRINT 'Dropped Table: ' + @name 

        SELECT @name = (SELECT TOP 1 [name] FROM sysobjects WHERE [type] = 'U' AND category = 0 AND [name] > @name ORDER BY [name]) 

    END 

    GO 

HostForLIFE.eu SQL Server 2014 Hosting
HostForLIFE.eu is European Windows Hosting Provider which focuses on Windows Platform only. We deliver on-demand hosting solutions including Shared hosting, Reseller Hosting, Cloud Hosting, Dedicated Servers, and IT as a Service for companies of all sizes.

 



About HostForLIFE.eu

HostForLIFE.eu is European Windows Hosting Provider which focuses on Windows Platform only. We deliver on-demand hosting solutions including Shared hosting, Reseller Hosting, Cloud Hosting, Dedicated Servers, and IT as a Service for companies of all sizes.

We have offered the latest Windows 2016 Hosting, ASP.NET Core 2.2.1 Hosting, ASP.NET MVC 6 Hosting and SQL 2017 Hosting.


Tag cloud

Sign in