Tag: tricks
UPDATE from SELECT query in SQL Server
Assume a scenario where you have a temporary table contains the data and would like to update a table using the values from the temporary table. Here’s an query demonstrating how to do it in SQL Server.
How to display Row Numbers in the results in SQL Query ?
If you want to return the row number as a part of your results in the SQL Query , you can use the ROW_NUMBER function and specify the ORDER BY clause to it as shown in this blog post. How to display Row Numbers in the results in SQL Query ?
How to Declare and Define an Long data type variable in F# ?
How to Declare and Define an Long data type variable in F# ?
Verify if the variable is a non-empty string in JavaScript
If you want to test if a variable that is defined is a non-empty string in JavaScript , you can use the typeof keyword to find if the type is a sring as well as check for the length of the string as shown below. How to verify if the variable is a non-empty string in JavaScript ? This will cause the else part to…
How to handle Null Column values of SQLDataReader in C# ?
If you want to handle the Null column values of the sqldatareader object in C#, you can use the SqlReader.IsDBNull method to validate for it. If the SqlReader.IsDBNull returns true then , the value is considered to be a null value and you can take the ction accordingly. How to handle Null Column values of SQLDataReader in C# ?
How to Get a value to a Variable in SQL Server ?
When you use the declare a variable using the DECLARE statement. The same variable can be used to store a value retrieved from the database and later can be used in your SQL Query. How to Get a value to a Variable in SQL Server ? For example , you want to retreive the value of the column JobTitle and store it in the variable…
How to Get the Desired Accuracy Level of Location using Geolocator in Windows Phone 8?
There are 3 different technologies that help the phone get the current location of the phone. These include Wifi, Cellular and A-GPS. Each one of these technologies has their own advantages and disadvantages in terms of the power consumption and the accuracy level. The Geolocator class allows the developers to specify at what level of accuracy or technology to be used to find the location…
How to return the SHA1 hash value of a string in SQL Server ?
SQL Server provides a function HashBytes function that returns the SHA1 , MD2 , MD4 and few other hash value of the specified input. How to return the SHA1 hash value of a string in SQL Server ? Just pass the ‘SHA1’ as the first parameter and the input as second parameter value to the HashBytes function to get the SHA1 hash value.
How to Copy the entire contents of a directory in C# ?
Below is a sample code snippets that demonstrates how to copy the entire contents of a directory to another in C#. How to Copy the entire contents of a directory in C# ?
SQL Server – Saving changes is not permitted. The changes you have made require the following tables to be dropped...
There are times when you get an error stating “Saving changes is not permitted. The changes you have made require the following tables to be dropped and re-created. You have either made changes to a table that can’t be re-created or enabled the option Prevent saving changes that require the table to be re-created.” You can easily resolve this issue by following the steps mentioned…
How to Derive a Class (Inheritance) in Javascript (WinJS) ?
If you want to derive a class from another class in Javascript when developing a Windows store app using WinJS library , you can use the WinJS.Class.derive method to do it. How to Derive a Class (Inheritance) in Javascript (WinJS) ? Below is a sample code snippet demonstrating how to derive a class in WinJS.
Example of Property Elements in Xaml
The Syntax for the property element in Xaml is as follows below TypeName.PropertyName The property elements are always contained inside a typename object and they don’t have the attributes of their own. An example of the property element is the Button.Content property which is used to set the content of the button control which is of type object. The Below code is used to set…
using IN clause to provide a list of values for Search Criteria
In SQL Server , you can use the IN clause to providing the list of values for a search criteria. For example , you want to display the employee records who’s job title is one of the following : ‘Design Engineer’,’Tool Designer’. The above query uses the IN clause to filter the employee records using the arbitrary list of values. Alternatively , you can also…
C Program to print a Half Pyramid using *
Problem Write a program in C to print Half pyramid using * as shown. * * * * * * * * * * * * * * * How to create and display Half Pyramid pattern in C ? Output Abundantcode.com Coding samples Enter the total number of rows: 5 * * * * * * * * * * * * * *…
Exit the Current Scope without returning a value in SQL Server
You can use the RETURN statement to discontinue the execution of a the T-SQL batch statement. For example , you want to display the Employees whose MaritalStatus is Divorced. You donot want the SQL Statements following it to be executed if this condition doesn’t match. You can use the IF NOT EXISTS and use the RETURN statement as shown in this example. The second statement…
Example of Anonymous Method in C#
Below is a sample code snippet that demonstrates how to use anonymous method to add two numbers in C#. Example of Anonymous Method in C#
Inner Join in SQL Server
You can use inner join to get the result of two tables that match the criteria. For example , assume that you have a Person table and a Phone Number table where every person would have 0 or more phone number associated to him and you wish to get the person records who have at least one phone number. Here’s the query on how to…
How to check if a column exists in a table in SQL Server ?
If you want to find out if a column exists in a SQL Server table , you can use the sys.columns table and specify the name of the column and table as parameter. How to check if a column exists in a table in SQL Server ? For example , you want to find out if the GroupName column exists in the table “HumanResources.Department” table…
Sleep Command in SQL Server
If you are looking at writing a query to sleep for or WAIT for a certain amount of time before the query execution can begin , you can use the WAITFOR command. For example , if you want to wait for 1 minute , the query or command for the same will be this.
Specify a port number when connecting to SQL Server in Management Studio
There are times when you want to connect to a SQL Server instance that is running on a different port number than default port (1433). How to specify a port number when connecting to a SQL Server instance in SQL Management Studio ? Just specify the SQL Server instance that you are connecting to along with the port number with comma as delimiter. For example…