Thursday, 9 July 2020

Types of SQL Server Backups

Overview
SQL Server offers many options for  creating backups.  In a previous topic, Recovery Models, we discussed what types of backups can be performed based on the recovery model of the database.  In this section we will talk about each of these backup options and how to perform these backups using SSMS and T-SQL.

Explanation
The different types of backups that you can create are as follows:


  • Full backups
  • Differential backups
  • File backups
  • Filegroup backups
  • Partial backups
  • Copy-Only backups
  • Mirror backups
  • Transaction log backups

Thursday, 4 June 2020

Live Darshan From Shree Kashi Vishwanath Temple Varanasi

Live Darshan From Shree Kashi Vishwanath Temple Varanasi
(श्री काशी विश्वनाथ मंदिर से लाइव दर्शन )


(courtesy https://bit.ly/3eOFj4R)

Friday, 20 March 2020

Best Practices for Personal Productivity


Best Practices for Personal Productivity:

  1. Structure your day like you would in the office: When working from home, you're your own personal manager. Without things like an in-person meeting schedule to break up your day, you can be quick to lose focus or burn out. To stay on schedule, segment what you'll do and when for the day. 
  2. Choose a dedicated workspace: Just because you're not working at an office doesn't mean you can't, well, have an office. Rather than cooping yourself up in your room or on the couch -- spaces that are associated with leisure time -- dedicate a specific room or surface in your home to work.
  3. Your calendar is sacred: Set timers for food breaks, leisure walks, time off, family obligations, etc. Call out good work! Do this more often than usual and with consistency. Start your meetings with kudos.
  4. Make it harder for yourself to mess around on social media: Social media is designed to make it easy for you to open and browse quickly. At work, though, this convenience can be the detriment of your productivity. To counteract your social networks' ease of use during work hours, remove them from your browser shortcuts and, according to Fast Company, log out of every account. You might even consider working primarily in a private or if you're using Chrome, an "Incognito" browser window. This ensures you stay signed out of all your accounts and each web search you conduct doesn't autocomplete the word you're typing. It's a guarantee that you won't be tempted into taking too many social breaks during the day.
  5. Commit to doing more: Projects always take longer than you initially think they will. For that reason, you'll frequently get done less than you set out to do. So, just as you're encouraged to overestimate how much time you'll spend doing one thing, you should also overestimate how many things you'll do during the day. Even if you come up short of your goal, you'll still come out of that day with a solid list of tasks filed under 'complete.'
  6. Work when you're at your most productive: Nobody sprints through their work from morning to evening -- your motivation will naturally ebb and flow throughout the day. When you're working from home, however, it's all the more important to know when those ebbs and flows will take place and plan your schedule around it.
    To capitalize on your most productive periods, save your harder tasks for when you know you'll be in the right headspace for them. Use slower points of the day to knock out the easier, logistical tasks that are also on your plate. Verily Magazine calls these tasks "small acts of success," and they can help build your momentum for the heavier projects that are waiting for you later on.
  7. Communicate expectations with anyone who will be home with you: Of course, you might be working from home but still have "company." Make sure any roommates, siblings, parents, spouses, etc. respect your space during work hours. Just because you're working from home doesn't mean you're home.
  8. Take clear breaks: It can be so easy to get distracted as a telecommuter that you avoid breaks altogether. Don't let the guilt of working in the building you sleep in prevent you from taking five to relax. Rather than just opening YouTube and watching some comfort clips, however, use your breaks to get away from your desk. Go for a walk outside or spend time with others who might also be in the house.
  9. Eat on time, eat healthy, stay hydrated: Set timelines for this on your calendar so you’re not skipping meals. Hydrate. Stretch every 30 minutes. Hydrate. Have strict timelines on when you eat. 
  10. Prepare your meals the night before: When you're in your own home, it can be tempting to spend time preparing a really nice breakfast and lunch for yourself, chopping and cooking included. Don't use precious minutes making your food the day of work -- cook it the night before.
    Preparing food ahead of time ensures you can actually use your meal times to eat, and that you aren't performing non-work tasks that spend energy better used at your desk.
  11. Pick a definitive finishing time each day: You might be under the impression that working from home establishes more work-life balance, but be careful with that assumption. Working from home can also feel confusing -- you can get so caught up in your activity, in a relaxing environment, that you lose complete track of time.
  12. Call out good work! : Do this more often than usual and with consistency. Start your meetings with kudos.

Wednesday, 18 March 2020

Web API authentication using certificate

RestSharp Example:




Get Example 
NameSpace

using RestSharp;

public IRestResponse GetExample(string URL)
{

var client = new RestClient(URL);
var request = new RestRequest(Method.GET);
//Add Header value
request.AddHeader("Cache-Control", "no-cache");
request.AddHeader("Accept", "application/json");
request.AddHeader("Content-Type", "application/json");
IRestResponse response = client.Execute(request);
return response;
}

Get Example  With Certificate 
public IRestResponse GetExampleWithCertificate(string URL)
{

var client = new RestClient(URL);
var request = new RestRequest(Method.GET);
//Add Header value
request.AddHeader("Cache-Control", "no-cache");
request.AddHeader("Accept", "application/json");
request.AddHeader("Content-Type", "application/json");
  X509Certificate2 certificate = new X509Certificate2();
 certificate.Import(System.Web.Hosting.HostingEnvironment.MapPath("Cerficate"), "", X509KeyStorageFlags.MachineKeySet);
                client.ClientCertificates = new X509CertificateCollection() { certificate };
IRestResponse response = client.Execute(request);

 SecurityProtocolType securityProtocols = ServicePointManager.SecurityProtocol;
            if (securityProtocols.HasFlag(SecurityProtocolType.Ssl3) || securityProtocols.HasFlag(SecurityProtocolType.Tls) || securityProtocols.HasFlag(SecurityProtocolType.Tls11))
            {
                securityProtocols &= ~(SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls | SecurityProtocolType.Tls11);
                if (securityProtocols == 0)
                {
                    securityProtocols |= SecurityProtocolType.Tls12;
                }
                ServicePointManager.SecurityProtocol = securityProtocols;
            }
ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
IRestResponse response = client.Execute(request);
return response;
}



Post Example

public IRestResponse PostExample(string URL)
{

var client = new RestClient(URL);
var request = new RestRequest(Method.Post);
//Add Header value
request.AddHeader("Cache-Control", "no-cache");
request.AddHeader("Accept", "application/json");
request.AddHeader("Content-Type", "application/json");
//Post Json
request.AddParameter("application/json", Requestjson, ParameterType.RequestBody);

IRestResponse response = client.Execute(request);
return response;
}

Get Example  With Certificate 
public IRestResponse PostExampleWithCertificate(string URL)
{

var client = new RestClient(URL);
var request = new RestRequest(Method.Post);
//Add Header value
request.AddHeader("Cache-Control", "no-cache");
request.AddHeader("Accept", "application/json");
request.AddHeader("Content-Type", "application/json");
//Post Json
request.AddParameter("application/json", Requestjson, ParameterType.RequestBody);
// Add Certificate
  X509Certificate2 certificate = new X509Certificate2();
 certificate.Import(System.Web.Hosting.HostingEnvironment.MapPath("Cerficate"), "", X509KeyStorageFlags.MachineKeySet);
                client.ClientCertificates = new X509CertificateCollection() { certificate };
IRestResponse response = client.Execute(request);

 SecurityProtocolType securityProtocols = ServicePointManager.SecurityProtocol;
            if (securityProtocols.HasFlag(SecurityProtocolType.Ssl3) || securityProtocols.HasFlag(SecurityProtocolType.Tls) || securityProtocols.HasFlag(SecurityProtocolType.Tls11))
            {
                securityProtocols &= ~(SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls | SecurityProtocolType.Tls11);
                if (securityProtocols == 0)
                {
                    securityProtocols |= SecurityProtocolType.Tls12;
                }
                ServicePointManager.SecurityProtocol = securityProtocols;
            }
ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
IRestResponse response = client.Execute(request);
return response;
}

Sunday, 15 March 2020

sqlcmd - Run Transact-SQL Script Files

Run the script file

  • Open a command prompt window.
  • In the Command Prompt window, type: sqlcmd -S myServer\instanceName -i C:\myScript.sql
  • Press ENTER.


Save the output to a text file

  • Open a command prompt window.
  • In the Command Prompt window, type: sqlcmd -S myServer\instanceName -i C:\myScript.sql -o C:\EmpAdds.txt
  • Press ENTER.
Run the script file with the Database username and password

  • Open a command prompt window.
  • In the Command Prompt window, type: SQLCMD -S <DBServerName> -U <DBUserName> -P <DBPassword> -d <DBName> -i C:\myScript.sql -o C:\EmpAdds.txt
  • Press ENTER.
sqlcmd Utility Syntax

sqlcmd   

  •    -a packet_size  
  •    -A (dedicated administrator connection)  
  •    -b (terminate batch job if there is an error)  
  •    -c batch_terminator  
  •    -C (trust the server certificate)  
  •    -d db_name  
  •    -e (echo input)  
  •    -E (use trusted connection)  
  •    -f codepage | i:codepage[,o:codepage] | o:codepage[,i:codepage] 
  •    -g (enable column encryption) 
  •    -G (use Azure Active Directory for authentication)
  •    -h rows_per_header  
  •    -H workstation_name  
  •    -i input_file  
  •    -I (enable quoted identifiers)  
  •    -j (Print raw error messages)
  •    -k[1 | 2] (remove or replace control characters)  
  •    -K application_intent  
  •    -l login_timeout  
  •    -L[c] (list servers, optional clean output)  
  •    -m error_level  
  •    -M multisubnet_failover  
  •    -N (encrypt connection)  
  •    -o output_file  
  •    -p[1] (print statistics, optional colon format)  
  •    -P password  
  •    -q "cmdline query"  
  •    -Q "cmdline query" (and exit)  
  •    -r[0 | 1] (msgs to stderr)  
  •    -R (use client regional settings)  
  •    -s col_separator  
  •    -S [protocol:]server[instance_name][,port]  
  •    -t query_timeout  
  •    -u (unicode output file)  
  •    -U login_id  
  •    -v var = "value"  
  •    -V error_severity_level  
  •    -w column_width  
  •    -W (remove trailing spaces)  
  •    -x (disable variable substitution)  
  •    -X[1] (disable commands, startup script, environment variables, optional exit)  
  •    -y variable_length_type_display_width  
  •    -Y fixed_length_type_display_width  
  •    -z new_password   
  •    -Z new_password (and exit)  
  •    -? (usage) 



Wednesday, 4 March 2020

Corona virus - COVID-19

कोरोना वायरस साइज में बड़ा होता है जिसका साइज 400-500 माइक्रोन का होता है, इसलिए ये नार्मल मास्क से भी रुक जाता है इसके लिए किसी खास मास्क की ज़रूरत नहीं है.

ये वायरस हवा में नही तैरता पर ज़मीन पर ज़िंदा रहता है, किसी भी तरह के मेटल पर ये 12 घंटे ज़िंदा रहता है, इसलिए हाथ को साबुन से धोते रहें!

ये कपड़ो पर 9 घंटे ज़िंदा रहता है तो इसलिए कपड़ो को रोज़ धोएं और धूप में सुखाये, 2 घण्टे धूप लगाये.

हाथों पे ये 10 मिनट ज़िंदा रहता है तो अल्कोहल वाला sanitizer उसे करें.

ये 26-27℃ से ज़्यादा का तापमान नहीं झेल पाता इसलिए धूप में ज़रूर जाएं और गरम पानी की गरारे करें ये मुँह में ही मर जायेगा, और फेफड़ों में नहीं जाएगा.

ठंडी चीज़े, icecream वगैरह ना खाएं.

इन् सब चीजों को धयान रख कर कोरोना से काफी हद तक बचा जा सकता है!

सुरक्षा टिप्स: 

१. हाथ के बजाये अपनी कोहनी, कन्धों का प्रयोग दरवाजों को खोलने और बंद करने के लिए करें
२. नमस्कार करें . हैंडशेक न करें.
३. अपनी नाक, आँख, और मुंह को अपने हाथ से न छुएँ (आप लगभग १०० x बार दिन भर में अपना हाथ मुंह पर ले जाते है)
४. ६०% से अधिक अल्कोहल वाले sanitizer की शीशी अपने जेब में ले कर चलें. जब भी कुछ छुएं हाथ साफ़ कर लें
५. मास्क वायरस से बचने के लिए नहीं है, बल्कि आप को अपने मुंह को छूने से रोकने के लिए पहने.
६. यह वायरस हवा में नहीं होगा. बल्कि खासने और छीकने पर उसके छीटों में होगा. यदि आप खांस रहे हैं तो डिस्पोजेबल टिश्यू का प्रयोग करें
७. और यदि कोई खांस रहा है तो उससे कुछ दूर रहे.
८. यह वायरस आपके फेफड़ों के सेल् को ही affect करता है. इसलिए यह केवल आपके हाँथ के द्वारा आपके नाक या मुहं से होता हुआ फेफड़ों में जाएगा या यदि कोई व्यक्ति आपके नाक या मुंह पर सीधे खांसे या छीक दे तब जायेगा .
९. जिंक Lozenges ले कर रख लें और जब गले या फेफड़ों में कुछ अजीब सा लगे तो उसे पीठ के बल लेट कर मुंह के एक दम पीछे वाले हिस्से में रख कर चूसें
१० अपना गला सूखने न दें. हर १० / १५ मिनट में पानी का सिप लेते रहे.
११ आपको कोरोना वायरस है की नहीं - जानने के लिये गहरी सांस लें और १० सेकंड के लिए सांस रोक लें. यदि आपको खांसी नहीं आये, सीने में कुछ भारीपन न हो, discomfort न  हो तो समझिये की आपको कोरोना नहीं है. रोज़ चेक करें

Upload valid file in C#

    protected bool CheckFileExtandLength(HttpPostedFile HtmlDocFile)     {         try         {             Dictionary<string, byte[]>...