Rss Feed Like Us on facebook Google Plus

June 28, 2016

Convert UTC Time to specific Time-Zone on SQL

Convert UTC Time to specific Time-Zone on SQL


CREATE FUNCTION [dbo].[ConvertDatewithZoneOffset]
(
 @DateTimeStamp DATETIME,
 @TimeZoneOffset VARCHAR(20)
)
RETURNS DATETIME
AS
BEGIN
 RETURN CONVERT(DATETIME, 
               SWITCHOFFSET(CONVERT(DATETIMEOFFSET, 
                                    DATEADD(hh, DATEDIFF(hh, GETDATE(), GETUTCDATE()), @DateTimeStamp)),@TimeZoneOffset)) 
END
Read More

Why is null not allowed for DateTime in C#?

DateTime is a value-type (struct), where-as string is a reference-type (class etc). That is the key difference. 

A reference can always be null; a value can't (unless it uses Nullable<T> - i.e. DateTime?), although it can be zero'd (DateTime.MinValue), which is often interpreted as the same thing as null 


C# that causes null DateTime error

using System;

class Program
{
    static void Main()
    {
 DateTime current = null;
    }
}

Results

error CS0037: Cannot convert null to 'DateTime'
because it is a non-nullable value type

Read More

Find dependency of a particular object with all procedures/Objects of a database

There are various methods to finds the dependent objects , there is a system defined procedures sp_depends but it does not give perfect result always as it give results on the basis of creation order, more accurate ways are below

If we need to find paymentdetail table dependency on procedures/objects ,then  query

will be

FIND Dependency 

SELECT DISTINCT so.name
FROM sys.syscomments sc
INNER JOIN sys.sysobjects so ON sc.id=so.id
WHERE sc.TEXT LIKE '%paymentdetail%'

OR

SELECT referencing_schema_name, referencing_entity_name,
referencing_id, referencing_class_desc, is_caller_dependent
FROM sys.dm_sql_referencing_entities ('dbo.First', 'OBJECT');



FIND Text in Procedures

select name  from sys.procedures
where OBJECT_DEFINITION(OBJECT_ID) like '%paymentdetail%'



Read More

January 22, 2015

Different types of SQL Keys : Key Constraints

Basically only Primary keys and foreign keys are two types of constraints that can be used to
enforce data integrity in SQL Server tables. These are important database objects. Others are the Database Concepts, these are also used to create relationship among different database tables or views.

Types of SQL Keys

We have following types of keys in SQL which are used to fetch records from tables and to make relationship among tables or views.

Super Key

Super key is a set of one or more than one keys that can be used to identify a record uniquely in a table.Example :Primary key, Unique key, Alternate key are subset of Super Keys.

Candidate Key(Surrogate Key)

A Candidate Key is a set of one or more fields/columns that can identify a record uniquely in a table. There can be multiple Candidate Keys in one table. Each Candidate Key can work as Primary Key.

Primary Key

Primary key is a set of one or more fields/columns of a table that uniquely identify a record in database table. It can not accept null, duplicate values. Only one Candidate Key can be Primary Key.

Alternate key

A Alternate key is a key that can be work as a primary key. Basically it is a candidate key that currently is not primary key.


Composite/Compound Key

Composite Key is a combination of more than one fields/columns of a table. It can be a Candidate key, Primary key.

Unique Key

Unique key is a set of one or more fields/columns of a table that uniquely identify a record in database table. It is like Primary key but it can accept only one null value and it can not have duplicate values. 

Foreign Key

Foreign Key is a field in database table that is Primary key in another table. It can accept multiple null, duplicate values. 

Check also:

Read More

November 5, 2014

Bypass the runonce web page to save Internet Explorer settings

IE7 changes my home page to http://go.microsoft.com/fwlink/?LinkId=74005


Solution 1 :
If Below Registry Exists then Change Values for these Registries to 1

KeyName: RunOnceHasShown
KeyType: REG_DWORD
KeyValue: 1


KeyName: RunOnceComplete
KeyType: REG_DWORD
KeyValue: 1


Solution 2 :
If Registry not Exists then Create these registries with same above configuration.

Problem Summary :
After installing Internet Explorer 7 all users are supposed to save their settings, the IE automatically redirects the page to "http://go.microsoft.com/fwlink/?LinkId=74005" which redirects to "http://runonce.msn.com/runonce2.aspx" till the user saves the settings to set their preferences such as the default search engine, whether turn on automatic Phishing Filter, language settings and so on.

If the customer does not want to be auto-directed to this web page, then they need to follow the below steps. Two values should be added/modified in the registry, so that IE 7 will go to the home page instead of the external link above:

1. Goto Run and Type regedit and press Enter.
2. Go to registry key:
[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main]
3. Right-click this key and select New -> DWORD Value.
4. On the right pane, create the new value to RunOnceComplete.
5. Right-click RunOnceComplete and click “Modify” and set the value data to 1.
6. Repeat Step 3 to Step 5 to create/modify the value name RunOnceHasShown and set the value data to 1.
7. Restart the IE 7 to see if it still visits the Save settings web site.

If you are familiar with using .REG files, then you can use what’s below to create one and use:

Windows Registry Editor Version 5.00


[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main]
"RunOnceComplete"=dword:00000001
"RunOnceHasShown"=dword:00000001

Note: IE7 will query the two values RunOnceComplete and RunOnceHasShown every time it starts. If these values have been set as depicted above, IE will visit the home page set in the IE control panel.
Read More

November 3, 2014

How to change password of wi-fi Router

  • Open Internet Explorer and type the 192.168.2.1 (Router Default IP)  and press enter.
  • You will be prompted to login panel, use admin as username and password:
 

After Login Router DashBoard will open
  •  Go to Wireless Tab and then wireless security under wireless.
     

  • After changing password click on Save Settings and after that it will prompt Settings Saved Successfully and then close the browser. your password has been changed
Read More

October 8, 2014

Outlook attachment is not open. Error: Permission not defined

Solution


Outlook 2003
If you are using Outlook 2003, follow these steps:
  1. Click My Computer, and then double-click drive C.
  2. On the File menu, click New, and then click Folder.
  3. Name the folder temp0.
  4. Click Start, click Run, type regedit, and then click OK.
  5. Locate and then click the following registry key:
HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Outlook\Security\
  1. In the right pane, double-click OutlookSecureTempFolder.
  2. In the Value Data field, type C:\temp0\ and then click OK.
  3. Exit Registry Editor.
  4. Restart the computer.
Outlook 2007
If you are using Outlook 2003, follow these steps:
  1. Click My Computer, and then double-click drive C.
  2. On the File menu, click New, and then click Folder.
  3. Name the folder temp0.
  4. Click Start, click Run, type regedit, and then click OK.
  5. Locate and then click the following registry key:
HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Outlook\Security\
  1. In the right pane, double-click OutlookSecureTempFolder.
  2. In the Value Data field, type C:\temp0\ (Directory Which is created) and then click OK.
  3. Exit Registry Editor.
  4. Restart the computer.
Outlook 2010 
If you are using Outlook 2010, follow these steps:
  1. Click My Computer, and then double-click drive C.
  2. On the File menu, click New, and then click Folder.
  3. Name the folder temp0.
  4. Click Start, click Run, type regedit, and then click OK.
  5. Locate and then click the following registry key:
HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\Outlook\Security\
  1. In the right pane, double-click OutlookSecureTempFolder.
  2. In the Value Data field, type C:\temp0\ and then click OK.
  3. Exit Registry Editor.
  4. Restart the computer.
Read More

September 16, 2014

Get Mobile Number of Sim Card on Android Device

You can use the TelephonyManager to do this:
TelephonyManager tm = (TelephonyManager)getSystemService(TELEPHONY_SERVICE); 
String number = tm.getLine1Number();
The documentation for getLine1Number() says this method will return null if the number is "unavailable", but it does not say when the number might be unavailable.
You'll need to give your application permission to make this query by adding the following to your Manifest:
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
(You shouldn't use TelephonyManager.getDefault() to get the TelephonyManager as that is a private undocumented API call and may change in future.)





Example

Activity Class Look Like This

Class
GetMyPhoneNoActivity 
package com.kns;
 
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.telephony.TelephonyManager;
import android.util.Log;
import android.widget.Toast;
 
public class GetMyPhoneNoActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);        
    
        String number =getMyPhoneNO();
        Toast.makeText(getApplicationContext(), "My Phone No is: "
        +number, Toast.LENGTH_SHORT).show();
        Log.v("Debug", number);        
    }
    
    private String getMyPhoneNO(){
     TelephonyManager mTelephonyMgr;  
     mTelephonyMgr = (TelephonyManager) getSystemService
       (Context.TELEPHONY_SERVICE);   
 
     String yourNumber = mTelephonyMgr.getLine1Number();
  return yourNumber; 
    }     
}

Permission in Manifest File
<uses-permission android:name="android.permission.READ_PHONE_STATE">
</uses-permission>


Read More

August 1, 2014

Recover SQL Server Database from Suspect Mode

If your Database goes to Suspected Mode you can try below queries to retrieve the database in normal mode.

Reason for database to go into suspect mode:
1.    Data files or log files are corrupt.
2.    Database server was shut down improperly
3.    Lack of Disk Space
4.    SQL cannot complete a rollback or roll forward operation.

  1. Open SQL Server Management Studio 
  2. Open new query window and execute some queries:

    • use master
    • Alter Database TestDataBase Set Emergency
    • ALTER DATABASE TestDataBase  SET SINGLE_USER
    • DBCC CHECKDB (TestDataBase , REPAIR_ALLOW_DATA_LOSS) WITH NO_INFOMSGS;
    • ALTER DATABASE TestDataBase SET MULTI_USER
    • ALTER DATABASE TestDataBase SET ONLINE
    • SELECT STATE_DESC FROM SYS.DATABASES WHERE NAME='TestDataBase'
  3. If all queries executed successfully, then database is recovered from suspected mode (some data may be loss after completion of this process. Ask the store to do PI after this process.).
Refresh your database server and verify the connectivity of your database. Now users should be able to connect to the database properly.

Read More

July 28, 2014

Ways to bring positivity in life

मुश्किलें उतनी ही बड़ी होती हैं, जितना आप सोचते हैं। कहते हैं आपकी सोच ही आपको कामयाब या नाकामयाब बनाती है। जिस व्‍यक्ति की सोच सकारात्‍मक होती है, उसके लिए कोई भी चुनौती बड़ी नहीं होती। वह जीवन के कठिन से कठिन हालात का सामना आसानी से कर सकता है। लेकिन, जिस व्‍यक्ति की सोच ऐसी नहीं होती, उसके लिए हर समस्‍या बड़ी होती है।

ध्यान:



ध्‍यान की महत्‍ता को अब वैज्ञानिक भी स्‍वीकार करते हैं। ऐसा माना जाता है कि जब आप ध्‍यान करते हैं तो आपका मस्तिष्‍क किसी एक विचार पर केंद्रित हो जाता है। ऐसे में उसमें से जो ऊर्जा निकलती है वह उसे मजबूत बनाती है। इससे इनसान जीवन की मुश्किल से मुश्किल परिस्थितियों का सामना करने के लिए तैयार होता है। दिन मं कम से कम 20 मिनट ध्‍यान जरूर लगाएं। किसी अंधेरे कमरे में ध्‍यान लगाने से आपको एकाग्र होने में आसानी होगी। दिमाग से सारे विचार निकाल दें। शुरुआत में यह प्रक्रिया मुश्किल लगेगी पर अभ्यास से यह काफी आसान हो जाएगा।

positive thinking:अपने व्‍यवहार पर रखें काबू



अपने आप से वादा करें कि आप नकारात्‍मक नहीं सोचेंगे। आपकी यही सोच आपको सकारात्‍मक बनाने में मदद करेगी। जिंदगी को देखने का आपका नजरिया ही आपको कामयाब बना सकता है। याद रखिये, अपनी जिंदगी के मालिक आप हैं, किसी दूसरे व्‍‍यक्ति को इसे चलाने का मौका और अधिकार न दें। ऐसा करना आपके लिए नुकसानदेह हो सकता है। अपनी जिंदगी से जुड़े सभी अहम फैसलों का हक आपको है और यह हक किसी दूसरे को न दें।

लक्ष्य पर टिके रहें:



जो आपको पसंद हो, वही आपका लक्ष्‍य होना चाहिए। अपने लक्ष्‍य पर टिके रहें ओर खुद पर विश्‍वास रखें। मुश्किलों से डर कर न तो अपना लक्ष्‍य बदलें और न ही हिम्‍मत हारें। खुले दिमाग और आशावादी सोच से आगे बढ़ते है, तो आपके कामयाब होने की संभावनाएं बढ़ जाती हैं। कड़ी मेहनत कर आगे बढ़ते रहें, आपके जीवन में सफलता जरूर आएगी। हर छोटे या बड़े लक्ष्य को पाने के बाद आपमें अपनी क्षमता को लेकर आत्मविश्वास आएगा।



positivity:खुद से पूछें सवाल



इनसान आसानी से बदलावों को स्‍वीकार नहीं करता। वह हर बदलाव पर सवाल उठाता है। अपने आप से पूछें आखिर आपके प्रतिरोध का मकसद क्‍या है, तो आपकी समझ में आएगा कि आखिर मुश्किल इतनी बड़ी है, जितनी आप सोच रहे हैं। यह सवाल उठाना आपके रक्षात्‍मक स्‍वभाव को कम करेगा। इससे आप कामयाबी के लिए नयी संभावनाओं को देख पाएंगे। आपको यह ध्यान रखना चाहिए कि सकारात्मक सोच सकारात्मकता लाती है जबकि प्रतिकूल सोच रखने वाले नकारात्मकता को अपने पास बुलाते हैं।

सकारात्मक लोगों से मिलें:



ऐसे लोगों से मिलें जिनकी सोच सकारात्‍मक हो। सकारात्मक विचारधारा वाले व्यक्तियों से मिलने से आपकी सोच और उद्देश्य भी सकारात्मक होंगे। और आप भी सकारात्‍मक तरीके से उन पर आगे बढ़ सकेंगे। नकारात्मक सोच रखने वाले लोग आपकी जिंदगी से सकारात्मकता को निकाल देते हैं वे लोग आपको भी नकारात्‍मक बना सकते हैं। हर व्‍यक्ति की अपनी तरंगें होती हैं, ऐसे लोगों के साथ रहें, जो आपको सकारात्‍मक तरंगे देते हों। कुछ ही दिनों में आपको अपने भीतर एक बदलाव महसूस होगा।
Read More

July 12, 2014

Detach, Attach and Restore the Database with Transact-SQL

Detach, Attach and Restore The Database with Transact-SQL using a test Database. Here i'm using 'MyDataBase' as Test DB.

Prerequisites

  • The database must first be detached. Attempting to attach a database that has not been detached will return an error.
  • When you attach a database, all data files (MDF and LDF files) must be available. If any data file has a different path from when the database was first created or last attached, you must specify the current path of the file.
  • When you attach a database, if MDF and LDF files are located in different directories and one of the paths includes \\?\GlobalRoot, the operation will fail.

Detach The Database

USE master
EXEC sp_detach_db 'MyDataBase', 'true';

Attach The Database

USE master
CREATE DATABASE MyDataBase
ON 
(FILENAME = 'D:\DataBase\MyDataBase.mdf'), -- Location where to store Data File
(FILENAME = 'D:\DataBase\MyDataBase_log.ldf') -- Location where to store Log File
FOR ATTACH;

Restore The DataBase (.Bak File)

USE master
RESTORE DATABASE MyDataBase
FROM DISK = 'D:\DATABASE\MyDataBase'  -- Location where Bak file resides
WITH 
MOVE 'MyDataBase(ThisFashion)_Data' TO 'D:\DataBase\MyDataBase.mdf'  -- Location where to store Data File
MOVE 'MyDataBase(ThisFashion)_Log' TO 'D:\DataBase\MyDataBase_log.ldf'  -- Location where to store Log File


Read More

June 19, 2014

Accordion with Jquery Toggle

Accordion Displays Collapsible Content on very less space. I am going to give a demo of  accordion using JQuery Toggle.

You can achieve this also by using bootstrap. to see an advance version you can checkout CSS Tricks Website.


DEMO


Lorem Ipsum 1+
Lorem Ipsum 2+
Lorem Ipsum 3+

Code

<html>
<head>
<style>
.accordion_container {
    width: 500px;
}
.accordion_head
{
    background: linear-gradient(0deg, #F79711, #DC7E03) repeat scroll 0 0 #D07906;
    color: white;
    cursor: pointer;
    font-family: segoe ui;
    font-size: 15px;
    margin: 0 0 1px 0;
    padding: 7px 11px;
    font-weight: bold;
    background-color: #D07906;
}
 
.accordion_body h3
{
    background-color: #CCCCCC;
    font-size: 20px;
    font-variant: small-caps;
    margin: 0;
    padding: 5px;
}
.accordion_body a.anchorButton
{
    font-size: 14px;
    padding: 2px 15px;
    float: right;
    width: auto;
    height: auto;
}
.accordion_body
{
    background: #f1f1f1;
}
.accordion_body p
{
    padding: 8px;
    margin: 0px;
}
.plusminus
{
    float: right;
}
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
    //toggle the componenet with class accordion_body
    $(".accordion_head").click(function(){
        if ($('.accordion_body').is(':visible')) {
            $(".accordion_body").slideUp(600);
            $(".plusminus").text('+');
        }
        $(this).next(".accordion_body").slideDown(600);
        $(this).children(".plusminus").text('-');
    });
});
</script>
</head>
    <div class="accordion_container">
        <div class="accordion_head">Lorem Ipsum 1<span class="plusminus">+</span></div>
            <div class="accordion_body" style="display: none;">
            <p>Lorem Ipsum 1 is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. </p>
            </div>
        <div class="accordion_head">Lorem Ipsum 2<span class="plusminus">+</span></div>
            <div class="accordion_body" style="display: none;">
            <p>Lorem Ipsum 2 .It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
            </div>
        <div class="accordion_head">Lorem Ipsum 3<span class="plusminus">+</span></div>
            <div class="accordion_body" style="display: none;">
            <p>Lorem Ipsum 3 is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.   </p>
            </div>
 
    </div>
</html>


Read More

© 2011-2016 Techimpulsion All Rights Reserved.


The content is copyrighted to Tech Impulsion and may not be reproduced on other websites.