Monday, 12 May 2014

Calling MS SQL Server user defined functions with default parameters

User Defined Function Call:

SELECT *
FROM udf_TestDef(1, DEFAULT)

Yes!! You have to insert the term default literary!

User Defined Function Sample:

CREATE FUNCTION [dbo].[udf_TestDef]
(
@Param INTEGER
@IsBigContainerPhoto BIT = 0
)
RETURNS TABLE
AS
RETURN
(
.
.
.

Sunday, 27 April 2014

Excel 2013: Removing a defined named range\data table

For normally defined name:
1) Formulas menu.
2) Name Manager.
3) Select the range and delete.


In my case that was a result of a query which generated the named data table:
1) Select the range from the drop down list beside the formula bar.
2) Right click on any cell within that range, and select:
Table --> Convert to Range





The reason I wanted to get rid of that named table in the first place was that filtering and sorting the data inside it was separated from the main sheet.

Tip: Creating Apple ID without entering credit card information

1) Start from the App Store from your device.
2) Try to install a free application.
3) When prompted to enter your Apple ID, select the option for creating a new account.
4) Fill in your information. Moreover, you will find an option for the payment which is "None"
This option is unavailable when you try to create your Apple ID the regular way through the website.


The following are the detailed instructions from Apple knowledge base:
http://support.apple.com/kb/ht2534


Thursday, 27 March 2014

Default value for SQLServerDatasource string parameter must contain a default value to be passed as empty string!

Scenario:
- FormView in edit mode with SQLServerDatasource update statement set to a stored procedure which contains a string, nvarchar(max), parameter.
- Within the aspx file, the default parameter value = ""
- Parameter is data binded to an empty TextBox.
- FormView is submitted for update.

Observation:
- Stored procedures string parameters when defaulted as empty strings, they are not passed to the stored procedure, rather than passed as empty strings.

Workaround# 1:
- Insert a space with the parameter default value in the aspx file such that:
default = " " rather than default = " ".

Workaround# 2:
- Handling the event SQLServerDataSource.Updating, so that to manually add a space within the parameter value when the TextBox.Text value is empty.


- Visual Studio 2013, version 12.0.30110.00 Update 1
- .NET Framework 4.0

Thursday, 20 March 2014

Wednesday, 26 February 2014

Determine user membership in active directory domain groups

C:>NET USER  /DOMAIN <username>
The request will be processed at a domain controller for domain <domain name>.

User name                    <username>
Full Name                    <FillName>
Comment
User's comment
Country code                 000 (System Default)
Account active               Yes
Account expires              Never

Password last set            09/02/2014 12:01:44 PM
Password expires             Never
Password changeable          09/02/2014 12:01:44 PM
Password required            Yes
User may change password     No

Workstations allowed         All
Logon script
User profile
Home directory
Last logon                   Never

Logon hours allowed          All

Local Group Memberships
Global Group memberships     *Domain Users         *Domain_2
The command completed successfully.

Wednesday, 19 February 2014

The database principal owns a database role and cannot be dropped.

SQL Command:
DROP USER [User_NAME]

Error Message:
The database principal owns a database role and cannot be dropped.

Solution:
SELECT T2.Name, T1.Name
FROM sys.database_principals AS T1 JOIN sys.database_principals AS T2 ON T1.owning_principal_id = T2.principal_id
 WHERE T1.type = 'R' AND T2.name = 'USER_NAME'

Output:
Database roles from which to remove this user before re-trying the deletion.