
August 23, 2016 21:54 by
Peter
In this post, i will tell you about ng ng-options instance but remove the selected items from previous uses in Angularjs. Now write the following code:

<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="utf-8" />
<script src="Scripts/angular.js"></script>
<link href="Content/bootstrap.css" rel="stylesheet" />
<script>
var app = angular.module('myApp', []);
app.controller('demoCtrl', function ($scope)
{
$scope.options = [
{
name: 'Apple',
id: '1'
},
{
name: 'Orange',
id: '2'
},
{
name: 'Banana',
id: '3'
},
{
name: 'Pear',
id: '4'
}, ];
});
</script>
</head>
<body>
<div ng-app="myApp" ng-controller="demoCtrl">
<div class="form-group col-md-3">
<label for="select1">Select 1:</label>
<select ng-model="newForm.select1" ng-options="option.name as option.name for option in options" class="form-control">
<option value=""></option>
</select>
</div>
<div class="row">
<br> </div>
<div class="form-group col-md-3">
<label for="select2">Select 2:</label>
<select ng-model="newForm.select2" ng-options="option.name as option.name for option in options | filter: newForm.select1 && {name: '!' + newForm.select1}" class="form-control">
<option value=""></option>
</select>
</div>
</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.


August 11, 2016 21:32 by
Peter
In this post, I'll share few useful SQL queries for database analysis on SQL Server 2012. I shared few SQL queries useful in analyzing database, which I use quite often. This query will return all table names and no.of rows in it for built-in tables.

-- List all table names and number of rows in it for user-defined tables
SELECT distinct t.name,prt.rows
FROM sys.tables t INNER JOIN sys.partitions AS prt
ON t.object_id = prt.object_id where t.is_ms_shipped=1 -- 0 for user-defined tables
order by prt.rows desc
This query will return column names and its data type of a table.
-- Get column names and its types of a table
SELECT cols.name,t.name
FROM sys.objects o join sys.columns cols on o.object_id= cols.object_id
join sys.types t on t.system_type_id=cols.system_type_id
and o.name='Employee'-- Table Name
This query will return file name, its size and file group name of a database.
SELECT sdf.name AS [FileName],
size/128 AS [Size],
fg.name AS [File_Group_Name]
FROM sys.database_files sdf
INNER JOIN
sys.filegroups fg
ON sdf.data_space_id=fg.data_space_id
Batch file to execute all sql files in a directory, Save it as .bat in a folder that have sql script files to be executed.
@Echo Off
FOR /f %%i IN ('DIR *.Sql /B') do call :RunSql %%i
GOTO :END
:RunSql
Echo Executing SQL: %1
SQLCMD -S server1 -U user1 -P pwd1 -d DB1 -i %1
Echo Completed SQL: %1
:END
This query will return all table names that have a Foreign key:
SELECT SCHEMA_NAME(schema_id) AS SchemaName,
name AS TableName
FROM sys.tables where OBJECTPROPERTY(OBJECT_ID,'TableHasForeignKey') = 1 -- Return all
HostForLIFE.eu SQL Server 2012 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.


August 4, 2016 23:28 by
Peter
The tSQLt unit test framework that we use to do our db tests doesn't give disabled tests, this can be because each test is just a keep proc. Right now the only way is to either rename the proc so it doesn’t start with test or to remove the test. Here is a quick way how to prevent a test from running when the tSQLt tests run.

Put the code below into each unit test that you want disabled, you should put this code right after the CREATE PROCEDURE ProcName AS part. This code will pick the correct name and schema, so you can use the same exact code in each test.
DECLARE @IsTestDisabled bit = 1 -- set this to 1 if you don't want the test to run
IF @IsTestDisabled =1
BEGIN
DECLARE @SchemaName varchar(1000)
SELECT @SchemaName = QUOTENAME(SCHEMA_NAME(schema_id)) +'.'
FROM sys.procedures WHERE object_id = @@procid
PRINT 'Disabled Test: ' + @SchemaName + QUOTENAME(OBJECT_NAME(@@procid))
RETURN
END
So if we grab the example test from the tSQLt website. We would change it from this
CREATE PROCEDURE testFinancialApp.[test that ConvertCurrency converts using given conversion rate]
AS
BEGIN
DECLARE @actual MONEY;
DECLARE @rate DECIMAL(10,4); SET @rate = 1.2;
DECLARE @amount MONEY; SET @amount = 2.00;
SELECT @actual = FinancialApp.ConvertCurrency(@rate, @amount);
DECLARE @expected MONEY; SET @expected = 2.4; --(rate * amount)
EXEC tSQLt.AssertEquals @expected, @actual;
END;
GO
To this
CREATE PROCEDURE testFinancialApp.[test that ConvertCurrency converts using given conversion rate]
AS
DECLARE @IsTestDisabled bit = 1 -- set this to 1 if you don't want the test to run
IF @IsTestDisabled =1
BEGIN
DECLARE @SchemaName varchar(1000)
SELECT @SchemaName = QUOTENAME(SCHEMA_NAME(schema_id)) +'.'
FROM sys.procedures WHERE object_id = @@procid
PRINT 'Disabled Test: ' + @SchemaName + QUOTENAME(OBJECT_NAME(@@procid))
RETURN
END
BEGIN
DECLARE @actual MONEY;
DECLARE @rate DECIMAL(10,4); SET @rate = 1.2;
DECLARE @amount MONEY; SET @amount = 2.00;
SELECT @actual = FinancialApp.ConvertCurrency(@rate, @amount);
DECLARE @expected MONEY; SET @expected = 2.4; --(rate * amount)
EXEC tSQLt.AssertEquals @expected, @actual;
END;
GO
Now you will get the following in your tSQLt test run output
Disabled Test: [testFinancialApp].[test that ConvertCurrency converts using given conversion rate]
This will be right above this text
+----------------------+
|Test Execution Summary|
+----------------------+
I want this printed so we know we have disabled tests when we get a email whenever Jenkins kicks off these tests…..
To enable the test again, all you have to do is change the value from 1 to 0 here. So instead of
DECLARE @IsTestDisabled bit = 1
You would make it
DECLARE @IsTestDisabled bit = 0
HostForLIFE.eu SQL 2016 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.
