If you have File DSN on other Box you can copy *.dsn file and edit it if required.
Wednesday, November 14, 2012
Tuesday, November 13, 2012
How to find info about your PC
run from command line systeminfo
http://bshireesh.blogspot.ca/2008/11/know-configuration-of-your-pc.html
http://bshireesh.blogspot.ca/2008/11/know-configuration-of-your-pc.html
Tuesday, November 6, 2012
Useful links on SQL
Article about Using sp_who2
List of queries useful for troubleshooting SQL slowness (see 'Related Post' section)
List of queries useful for troubleshooting SQL slowness (see 'Related Post' section)
Monday, November 5, 2012
How to truncate SQL Log
In management studio:
- Right-click the database, choose properties, then options.
- Make sure "Recovery model" is set to "Simple", not "Full"
- Click Ok
- Right-click the database again, choose tasks -> shrink files
- Change file type to "log"
- Click ok.
Alternatively, the SQL to do it:
ALTER DATABASE mydatabase SET RECOVERY SIMPLE
DBCC SHRINKFILE (mydatabase_Log, 1)
Thursday, October 25, 2012
Process Monitoring Tools
1. Process Monitor v3.0.3
Process Monitor is an advanced system monitoring tool that enables you to monitor file system, Registry and process/thread activity in real-time. It offers filters and highlighting rules that enables you to limit and focus the... [Read more]
Tuesday, October 23, 2012
Why cursor is a bad idea?
Cursor is a bad idea, since it lock a table used to populate a cursor while you loop through the cursor and do some operation on fetched records.
Here is some article about it http://www.sqlbook.com/SQL/Avoiding-using-SQL-Cursors-20.aspx
Here is some article about it http://www.sqlbook.com/SQL/Avoiding-using-SQL-Cursors-20.aspx
Monday, October 22, 2012
Read Committed and Repetable Read
Good article on it in StackOverflow
1) The default isolation level of Read Committed means that Dirty Reads will not occur (although phantom or non-repeatable reads might). It does not guarantee that single rows are locked.
A non-repeatable read can occur in the following situation:
1. Transaction 1 begins2. Transaction 1 read a row3. Transaction 2 begins4. Transaction 2 changes the value of the same row read by Transaction 1
5. Transaction 2 commits6. Transaction 1 reads the row again. Transaction 1 has inconsistent data.
2) Repeatable Read isolation level means the above situation cannot occur (though phantom reads still might). A phantom read can occur in the following situation:
1. Transaction 1 begins2. Transaction 1 read a row3. Transaction 2 begins4. Transaction 2 deletes the row read by Transaction 1
5. Transaction 2 commits. Transaction 1 can no longer repeat its initial read,
since the row no longer exists.
If you want to guarantee that data does not chnage while you read it, you would need the Serializable isolation level. I would strongly advise agianst not using the Serializable isolation level unless you absolutely have to, as concurrency will suffer.
Wednesday, October 10, 2012
Friday, September 28, 2012
Creating new root certificate
In SSL communication you would need a certificate signed by recognized CA. You can generate the new certificate, but if it is not signed by root certificate it would not be excepted. Is this possible to generate a root certificate without having access to recognized CA. The answer is yes
See article SSL with Self-hosted WCF Service for more detail. It also shows how to generate new certificate, sign it by the root certificate and associate it with a port.makecert -sv SignRoot.pvk -cy authority -r signroot.cer -a
sha1 -n "CN=Dev Certification Authority" -ss my -sr localmachine
Difference between cluster and cloud computing
Although these two paradigms are similar they can be distinguished be the following
1. clusters usually have corporate access, while clouds have public access through internet
2. clusters have not usage measurement, while clouds do and actually and it provide service by demand
3. resources are usually pre-reserved in clusters while in clouds they are demand driven (rapid elastic)
Here is a good article WHAT ARE THE DIFFERENCE BETWEEN CLOUD, CLUSTER AND GRID COMPUTING?
1. clusters usually have corporate access, while clouds have public access through internet
2. clusters have not usage measurement, while clouds do and actually and it provide service by demand
3. resources are usually pre-reserved in clusters while in clouds they are demand driven (rapid elastic)
Here is a good article WHAT ARE THE DIFFERENCE BETWEEN CLOUD, CLUSTER AND GRID COMPUTING?
Thursday, September 13, 2012
Tips and Triks
How To Show Full File Path in VS 2005 Title Bar
Unattended Service installation
installUtil.exe /username=domain\username /password=password /unattended C:\My.exe
Unattended Service installation
installUtil.exe /username=domain\username /password=password /unattended C:\My.exe
Wednesday, September 12, 2012
Useful commands/statements
1. Check if Procedure exist before creating it
EXISTS (SELECT * FROM sys.objects WHERE type = 'P' AND name = 'MyProc')
Return bool
Ex.
IF EXISTS (SELECT * FROM sys.objects WHERE type = 'P' AND name = 'MyProc')
DROP PROCEDURE MyProc
GO
CREATE PROCEDURE MyProc...
2.
SET NOCOUNT ON - Stops the message indicating the number of rows affected by a Transact-SQL statement from being returned as part of the results.
For stored procedures that contain several statements that do not return much actual data, this can provide a significant performance boost because network traffic is greatly reduced.
3. SP
sp_help [object] provides info on object
Monday, July 30, 2012
Sharing files between VirtualBox host OS and and guest OS
How to share files between host OS and guest OS in VirtualBox.
Host OS: Windows 7
Guest OS: Linux version Ubuntu
Create Shared Folder. Settings -> Shared Folders. Click on add icon, specify Folder Path and Folder Name, check Auto-mount. Folder Path is path on Host OS to be shared. Folder Name is a reference used by guest OS.
VirtualBox will create folder sf-[Folder Name] under /media .
There is a pitfall here. This directory is not accessible. Access permission to this directory is not given by default to the user who install VirtualBox and set up Shared Folder.
Here is instruction of how to grant the access permission to this directory (see )
Host OS: Windows 7
Guest OS: Linux version Ubuntu
Create Shared Folder. Settings -> Shared Folders. Click on add icon, specify Folder Path and Folder Name, check Auto-mount. Folder Path is path on Host OS to be shared. Folder Name is a reference used by guest OS.
VirtualBox will create folder sf-[Folder Name] under /media .
There is a pitfall here. This directory is not accessible. Access permission to this directory is not given by default to the user who install VirtualBox and set up Shared Folder.
Here is instruction of how to grant the access permission to this directory (see )
- Open a terminal.
- Enter "su -" (without quotes), hit Enter.
- Enter the root password, hit Enter.
- Type in "usermod -a -G vboxsf username", without quotes, replacing username with the user you want to add to the group, hit Enter.
- You may have to reboot to remount the share, the easiest way to do this is probably to reboot the VM.
Sunday, July 29, 2012
Permutation algorithms
Find out all possible permutation of set of string.
We assume that a given set is lexicographical sorted set.
Algorithm of finding next permutation (we start with original element)
step 1 find left atom
step 2 find right element
step 3 swap
step 4 reverse the order of tail of index of left element (before swapping)
Find left atom. Start with next to the last atom. Move left until the current atom is less then next to it atom. This atom will be left atom.
Find right atom. Start with the last atom. Move left until the current element is great found left element.
Example. Next to the element { "1" "3" "5" "4" "2" "0" }
| |
1 step - left is "3", atoms[1] (current atom "5" less then "3")
2 step - right is "4", atoms[3] (atom "4" is great then "3")
3 step - "1" "4" "5" "3" "2" "0"
4 step - "1" "4" "0" "2" "3" "5" (reverse tail of atoms[1] )
Example. A B C
1. left = B right = C.
A C B -> A C B
2. left = A right = B
B C A -> B A C
3. left = A right = C
B C A -> B C A
5. left = B right = C
C B A =>C A B
6. left = A right=B
C B A => C B A
Code
Here is a good article
We assume that a given set is lexicographical sorted set.
Algorithm of finding next permutation (we start with original element)
step 1 find left atom
step 2 find right element
step 3 swap
step 4 reverse the order of tail of index of left element (before swapping)
Find left atom. Start with next to the last atom. Move left until the current atom is less then next to it atom. This atom will be left atom.
Find right atom. Start with the last atom. Move left until the current element is great found left element.
Example. Next to the element { "1" "3" "5" "4" "2" "0" }
| |
1 step - left is "3", atoms[1] (current atom "5" less then "3")
2 step - right is "4", atoms[3] (atom "4" is great then "3")
3 step - "1" "4" "5" "3" "2" "0"
4 step - "1" "4" "0" "2" "3" "5" (reverse tail of atoms[1] )
Example. A B C
1. left = B right = C.
A C B -> A C B
2. left = A right = B
B C A -> B A C
3. left = A right = C
B C A -> B C A
5. left = B right = C
C B A =>C A B
6. left = A right=B
C B A => C B A
Code
public StringPerm Successor()
{
StringPerm result = new StringPerm(this.element);
int left, right;
// Step #1 - Find left value
left = result.order - 2;
while ((result.element[left].CompareTo(result.element[left + 1])) >= 0
&& (left >= 1))
{
--left;
}
if ((left == 0) &&
(this.element[left].CompareTo(this.element[left + 1])) >= 0)
{
return null;
}
// Step #2 - find right; first value > left
right = result.order - 1;
while (result.element[left].CompareTo(result.element[right]) >= 0)
{
--right;
}
// Step #3 - swap [left] and [right]
string temp = result.element[left];
result.element[left] = result.element[right];
result.element[right] = temp;
// Step #4 - reverse order the tail
int i = left + 1;
int j = result.order - 1;
while (i < j)
{
temp = result.element[i];
result.element[i++] = result.element[j];
result.element[j--] = temp;
}
return result;
}
Use recursion to get all permutation.Here is a good article
Monday, July 23, 2012
Tuesday, July 17, 2012
Useful command
1. Run as
runas /user:mkalai [executable]
2. Start and stop remote service from command line
Example
C:>net start "Ariel Document Mailing Dispatch Services"
Y:\>sc \\cm-pp-mts01 start "Ariel Document Mailing Dispatch Services"
Y:\>sc \\cm-pp-mts01 stop "Ariel Document Mailing Dispatch Services"
3. Finding info about your PC
systeminfo
runas /user:mkalai [executable]
2. Start and stop remote service from command line
sc \\machine stop <service>
sc \\machine start <service>
Example
C:>net start "Ariel Document Mailing Dispatch Services"
Y:\>sc \\cm-pp-mts01 start "Ariel Document Mailing Dispatch Services"
Y:\>sc \\cm-pp-mts01 stop "Ariel Document Mailing Dispatch Services"
3. Finding info about your PC
systeminfo
Thursday, July 5, 2012
Tips for Launching WCF Test Client
When you create WCF Service Library project the command Debug gets set as follows
Start Action: Start Project
Start Options
Command line arguments: /client:"WcfTestClient.exe"
When you want to launch your own client set specify your executable for /client switch and set Working directory to where the executable resides
Start Action: Start Project
Start Options
Command line arguments: /client:"WcfTestClient.exe"
When you want to launch your own client set specify your executable for /client switch and set Working directory to where the executable resides
Monday, June 25, 2012
SQL error handling
Use try/catch to handle errors
BEGIN TRY
. . .
END TRY
BEGIN CATCH
... (here you handle error and re-throw exception if you want. To throw exception you can do
something like this RAISERROR('your error msg', 16, 1). Severity must be 16
END CATCH
The following system function provide error info. It can be used to format error message for logging or re-throwing within from CATCH block.
BEGIN TRY
. . .
END TRY
BEGIN CATCH
... (here you handle error and re-throw exception if you want. To throw exception you can do
something like this RAISERROR('your error msg', 16, 1). Severity must be 16
END CATCH
The following system function provide error info. It can be used to format error message for logging or re-throwing within from CATCH block.
- ERROR_NUMBER() returns the number of the error.
- ERROR_SEVERITY() returns the severity.
- ERROR_STATE() returns the error state number.
- ERROR_PROCEDURE() returns the name of the stored procedure or trigger where the error occurred.
- ERROR_LINE() returns the line number inside the routine that caused the error.
- ERROR_MESSAGE() returns the complete text of the error message. The text includes the values supplied for any substitutable parameters, such as lengths, object names, or times.
Sunday, June 10, 2012
How to query database schema and objects
Run select statement against system object information_schema.tables for tables list and information_schema.columns for columns list
Example
Select table_name from information_schema.tables where table_name like '%cust%'
Select column_name from information_schema.columns where table_name = 'customers'
Sp sp_help [object] can be also helpful
How to find stored procedure that contains the given text
Sp sp_help [object] can be also helpful
How to find stored procedure that contains the given text
SELECT DISTINCT so.name FROM sys.sysobjects so
INNER JOIN sys.syscomments sc ON sc.id=so.id
WHERE sc.TEXT LIKE '%your tesxt%'
Tuesday, May 29, 2012
Code First Migration Links
1. EF3 Code First Migration Walkthrough.
http://blogs.msdn.com/b/adonet/archive/2012/02/09/ef-4-3-code-based-migrations-walkthrough.aspx
This post will provide an overview of the functionality that is available inside of Visual Studio for interacting with migrations. We will focus on the code-based workflow for using migrations. In this workflow each change is written out to a code-based migration that can reside in your project.
Main commands:
Add-Migration <MigrationName>
Update-Database
Run from Package Manager Console. Tools->Library Package Manager->Package Manager Console
2. Best books for SQL database
http://stackoverflow.com/questions/2413805/best-books-for-sql-server-database-design
2. Best books for SQL database
http://stackoverflow.com/questions/2413805/best-books-for-sql-server-database-design
Thursday, April 26, 2012
Wednesday, April 25, 2012
Reflector from RedGate
http://www.reflector.net/
Allows view, navigate, and search through the class hierarchies of .NET Assemblies even if you do not have the code for them.
Trial period 30 days.
Price: 70/130/190(VSPro)
Allows view, navigate, and search through the class hierarchies of .NET Assemblies even if you do not have the code for them.
Trial period 30 days.
Price: 70/130/190(VSPro)
Wednesday, March 14, 2012
Tuesday, March 6, 2012
How to read SQL error log
Run exec xp_readerrorlog
Wednesday, February 8, 2012
Optimistic concurrency in Entity Framework
To enable optimistic concurrency checking mark Entity property to be monitored for concurrency checking with attribute 'Concurrency Mode' as 'Fixed'. This can be done in properties window for a Entity property of interest in Entity Designer.
If any conflict occurs OptimisticConcurrencyException will be thrown.
If any conflict occurs OptimisticConcurrencyException will be thrown.
Wednesday, February 1, 2012
SSL access configuration for WCF
SSL will be used when Transport is set for wsHttpBinding
Apparently if mode is set to 'None' then any security requirements which would include SSL will be removed.
<wsHttpBinding>
<binding>
<security mode="None">
<transport clientCredentialType="None" />
</security>
</binding>
</wsHttpBinding>
Subscribe to:
Comments (Atom)