Consider
the following scenario: Your database has a table called Customer (who
doesn't these days) with millions of rows (lucky you). You production
support team just called you in the middle of the night with a live site
issue - Around 10,000 customers are getting a message that their logins
have been disabled. And they send you a text file with 10,000 customer
id's :-)
Great! Now you need to look these customers up in the database and enable their access again.
So
how can you load these 10K values from a text file into SQL? One way
would be to edit the text file, replace each new line with a comma and
then use the resulting string in the select clause as shown:
select * from Customer where Id in (1, 2, 6, 8, 10)
Now this might prove to be too much non-techy way. You are a programmer, right? You don't hard-code stuff! You write code!!
So how can you load these disabled customer list in the database programatically?
Create
a temporary table and call it DisabledCustomers with just one column
(name it Id and make sure it allows nulls and is not primary key - just
in case your list from support has duplicates).
Run the following SQL to load the values from the file into this table.
BULK INSERT dbo.DisabledCustomers
FROM 'c:\temp\customerids.txt'
WITH
(
ROWTERMINATOR ='\n'
)
Now your select statement becomes quite simple:
select * from Customer c
inner join DisabledCustomers dc on c.Id = dc.Id
Many
production systems have BULK INSERT disabled? As an exercise to you, my
dear reader, I look forward to seeing some innovative solutions to
that.
Nikhil Singhal's blog dedicated to helping you master the art of programming interviews.
- Introduction
-
Beginners
Simple coding questions–Part 1 How to find if a number is a Palindrome? Linked lists demystified Recursion–concepts and code Linked Lists – Sorting, Searching, Finding Maximum and Minimum Reverse a Linked List Searching algorithms–Linear search Binary Search String manipulation can be fun String pattern matching String functions galore Pass by value versus reference in C# How to find if a number is perfect square
-
Advanced
Lost in a Forest of Trees The Ins and Outs of a Binary Search Tree Simple Patterns: Singleton Pattern Simple Patterns: Repository Pattern Simple Patterns: Factory Pattern Implement a basic Stack using linked List Implement a Queue data structure using a linked list Operator overloading and pairing rules in C# LINQ Query, Selection, Partial Selections and Aggregations Explain System.IO and System.IO.Compression namespaces with an example How to Boost your Self-Confidence Distributed vs Parallel computing SOA interview questions Data migration strategies and design patterns
-
ASP.NET
How to redirect user to another page using ASP.NET Return different HTTP response codes from Response... Tracing page execution in ASP.NET ASP.NET page validation controls ASP.NET 4 site navigation using sitemaps How do you serialize an object to and from XML Manage state across entire application in ASP.NET How to monitor file system changes using FileSystemWatcher in C# ASP.NET @ Page directive How to add HTML Server Controls to a Web Page Using ASP.NET ASP.NET AJAX using UpdatePanel control ASP.NET Session modes explained Explain ASP.NET data binding using DataSets and DataSourceControls ASP.NET HttpModule explained ASP.NET HttpHandlers Asp.Net MVC interview questions
-
jQuery
jQuery AJAX functions part 1–the load() method jQuery AJAX functions part 2–get(), post(), getScript() and getJSON() jQuery AJAX functions part 3–ajax() Differentiate between alert(), prompt() and confirm() methods jQuery fadeIn, fadeOut and fadeTo effects jQuery Selectors reviewed jQuery to block paste in a textbox jQuery to create default text for a textbox jQuery to select/deselect all items in a CheckBoxList jQuery to show big image on hover
- SQL
- LINQ
- JAVA
-
Entity Framework
Entity Framework interview questions Entity Framework and eager loading of related entities interview questions Entity Framework and lazy loading interview questions Entity Framework transaction scope examples Entity Framework – what are the different ways to configure database name? Entity Framework - Explain ENUM usage in EF5
Please navigate to the bottom of the page for Table of Contents
Wednesday, March 20, 2013
Subscribe to:
Post Comments (Atom)
done lot of bulk insert while converting unix system to asp.net..
ReplyDeleteApprove, we should take a gander at Mark Twain's Huckleberry Finn to perceive how this functions. The novel opens with the acclaimed words "You don't think about me, without you have perused a book by the name of 'The Adventures of Tom Sawyer,' however that ain't regardless." So who or what is the great reader, the Stradivarius, to be here?text to speech online free save to mp3
ReplyDeleteThis is sure to help with enhancing proficiency aptitudes and having better broad speech. notevibes.com
ReplyDeleteseo
ReplyDeleteIn terms of competition levels. https://onlineearningmentor.com/search-engine-optimization challenge we certainly have when possessing an exercise is so it will be bad weather as well as get these consumers in the front door. We have been generally researching ways to equally develop the organization and offer the general public.
ReplyDeleteEach time I used to always check blog posts within the first hours in the break of day, because I like to get information increasingly more.
ReplyDeletehttp://listleveragereview.net/
Your articles and contents are encouraging.
ReplyDelete4liferesearchreview.com
That they had well project management skills and were in communication frequently website design agencies was receptive to feedback and implemented it accordingly. The collaboration was a hit.
ReplyDeleteKeep the ball rolling you have done the great job here.
ReplyDeleteWeb Site
The superb highly informative blog I’m about to share this with all my contacts.
ReplyDeleteSan Francisco web design
You have really selected the suitable topic; this is one of my favorite blogs.
ReplyDeleteuser experience agency
Keep the ball rolling you have done the great job here.
ReplyDeletehttps://www.youtube.com/watch?v=gtEYCdE0qZ8
Wow, amazing post! Really engaging, thank you.
ReplyDeleteApache Spark Training in Pune
Spark Training Institute in Pune
Compre documentos en línea, documentos originales y registrados.
ReplyDeleteAcerca de Permisodeespana, algunos dicen que somos los solucionadores de problemas, mientras que otros se refieren a nosotros como vendedores de soluciones. Contamos con cientos de clientes satisfechos a nivel mundial. Hacemos documentos falsos autorizados y aprobados como Permiso de Residencia Español, DNI, Pasaporte Español y Licencia de Conducir Española. Somos los fabricantes y proveedores de primer nivel de estos documentos, reconocidos a nivel mundial.
Comprar permiso de residencia,
permiso de residenciareal y falso en línea,
Compre licencia de conducir en línea,
Compre una licencia de conducir española falsa en línea,
Comprar tarjeta de identificación,
Licencia de conducir real y falsa,
Compre pasaporte real en línea,
Visit Here fpr more information. :- https://permisodeespana.com/licencia-de-conducir-espanola/
Address: 56 Guild Street, London, EC4A 3WU (UK)
Email: contact@permisodeespana.com
WhatsApp: +443455280186
really infomative and eduvcative article thanks publisher for sharing this info with us massage gaming chair with footrest whatsaup flippzilla
ReplyDeleteinformative article thanks for shairng this wonderful info gossip mouth
ReplyDeleteI'm certainly very happy to read this blog site posts which carries plenty of helpful data, thanks for providing such information.
ReplyDeletedesign beast review
This blog is very informative the stuff you provide I really enjoyed reading.
ReplyDeleteapp agency
Nice answers in replace of the question with real point of view and explaining about that.
ReplyDeletetop digital design agencies
I'm certainly very happy to read this blog site posts which carries plenty of helpful data, thanks for providing such information.
ReplyDeleteUI UX service
I'm also visiting this site regularly, this web site is really nice and the users are genuinely sharing good thoughts.
ReplyDeleteUX UI design studio
Aivivu - đại lý chuyên vé máy bay trong nước và quốc tế
ReplyDeleteVe may bay di My
lich bay tu my ve vietnam
các chuyến bay từ nhật về việt nam
vé máy bay khứ hồi từ đức về việt nam
đăng ký bay từ canada về Việt Nam
vé máy bay từ hàn quốc về việt nam bao nhiêu tiền
vé máy bay đi hàn quốc khứ hồi bao nhiêu tiền
Understanding what is expected out of an assignment is the first step of assignment writing. Reading the assignment topic thoroughly, analyzing it and any instructions given with the assignment help you get a clear picture of what you need to include in your assignment writing. prepare assignment
ReplyDelete