.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

how to write solid code for this case

Posted By:      Posted Date: October 25, 2010    Points: 0   Category :Sql Server

here is a common scenario:

insert into table A

select xx, xx, xx

from table B -- where B has the rows we want to insert, but need to join to table C to get some more info

inner join table C

on ......

the problem is, if there is any missing data in table C, we might lose data.  because of the missing data. but using left join will also cause issues for possible NULLs etc.

is there a good coding practice that will do the insertion and check for possible issues, for example, break and raise error if i find missing data becuase of the joins?



View Complete Post

More Related Resource Links

Share Code: Write Code Once For Both Mobile And Desktop Apps


If you're building .NET client apps already, target them to Windows Mobile using the same skills and toolsets.

Daniel Moth

MSDN Magazine July 2007

Wandering Code: Write Mobile Agents In .NET To Roam And Interact On Your Network


In artificial intelligence, an agent is a logical entity that has some level of autonomy within its environment or host. A mobile agent has the added capability that it can move between hosts. In this article Matt Neely brings mobile agents from the halls of academia to a dev shop near you.

Matt Neely

MSDN Magazine February 2006

C++: Write Faster Code with the Modern Language Features of Visual C++ 2005


The next version of Visual C++ has a new syntax that is both elegant and powerful. It has new optimization technology that has improved the speed of Microsoft. It has new compilation modes that ensure Common Language Infrastructure compliance and verifiability for the .NET Framework, and it has new models for interop. In this article Stephen Toub explains these and other improvements to Visual C++.

Stephen Toub

MSDN Magazine May 2004

Code write file asp.net 2.0 is working in firefox but IE not working.

If Not IsDBNull(ext) Then                                        ext = LCase(ext)                                    End If                                    Select Case ext                                        'Case ".htm", ".html"                                        '    type = "text/HTML"                   


HI. I NEED LITTLE HELP. I have values 1000,2000,3000, wich located in numValue. Now I have sql table CUSTOM1 with column CUSTOM_ID where located numbers 1000,1001,2005,2006 .. Now if I choose( NumValue == 1000) go to sql table and find Maximum number wich begin with 1000 and add 1 = Result must be 1002 there is my code what change I must do in order to receive the num max + 1?       DataTable dt = new DataTable();         SqlConnection con = new SqlConnection("Data Source=DYS-PC;Initial Catalog=Veolia;Integrated Security=True");         SqlCommand cmd = new SqlCommand("Select Count(*) " + "FROM [MHGROUP].CUSTOM1 " + "WHERE CUSTOM_ALIAS = '" + comboBox2.Text + "'", con);         SqlDataAdapter sqlDa2 = new SqlDataAdapter();         sqlDa2.SelectCommand = cmd;         sqlDa2.Fill(dt);      

how to write a code for browser compatible in asp.net 2.0

how to write a code for browser compatible in asp.net 2.0 How to write a code in asp.net for all browser compatible  

Changing case of all URLs in the website source code from Sentence to Lower

I only want to change case (Mixed to small) of URL in HREF attribute, nowhere else. This is just for convention purpose. eg changing   Its <a href="http://www.abc.com/S pecial-E dition.aspx">Special Ediation</a>.  View <a href="http://www.abc.com/O ther-N ews.aspx">Other News</a>.   to   Its <a href="http://www.abc.com/s pecial-e dition.aspx">Special Ediation</a>.  View <a href="http://www.abc.com/o ther-n ews.aspx">Other News</a>.

Query help to write case statement in Where clause?

Hi All, I have table something like this:- SELECT UserName, IsManager FROM Employee IsManager has only two values either 1 (which means user is a Manager) or 0 (which means user is not a Manager) Now I want to write below query:- DECLARE @IsManager INT SET @IsManager = 2 SELECT UserName, IsManager FROM Employee WHERE IsManager = CASE WHEN @IsManager = 1 THEN 1 WHEN @IsManager = 0 THEN 0 WHEN @IsManager = 2 THEN 1 | 0 ----- THIS IS NOT WORKING, when I set @IsManager value to 2 then where clause should be like this "IsManager = 1 OR IsManager = 0" END Can anybody help me out in modifying about query so that it produces both the results when @IsManager variable value "2". Thanks Regards, Kumar

Where to write the code for mail in master page

below is my code. please anyone tell me where to write vbscript to send email after validating the fields<%@ Page Language="VB" MasterPageFile="~/Master.master" AutoEventWireup="false" CodeFile="Enquiry.aspx.vb" Inherits="Enquiry" title="Enquiry - MTM Active" %><asp:Content ID="Content1" ContentPlaceHolderID="ConPage" Runat="Server"><script type="text/javascript" src="Js/Blank.js"></script><script type ="text/javascript">function CmdSubmit_onclick(){if (fnValidate()==true)return true;else return false;}function fnValidate() {if(IsBlank(" Name",document.getElementById ("TxtName").value)==false)        {            document.getElementById ("TxtName").focus();            return false;         }        if(IsBlank(" Email",document.getElementById ("TxtEmailID").value)==false)        {            document.getElementById ("TxtEmailID").focus();            return false;    &n

HOW can i write code for scrolling images in asp.net

plz help me in this topic in one perticular area the image should scroll for every 45 sec's

write server side code in External JS files

Salam To All,for my JS code, some times i need to organize my code, so i prefer to put some of javascript functions in external js files and  include it in my page as well.but i am face a problem if i need to write some .Net code especially to Get the Client ID for any of .net controls.so do you have a way to write the following code in External JS file?('#<%= this.ddlMake.ClientID %>').change(function(

how write code in my javascript function and modify it?


hi there
i have a function in my javascript code:

   <script language="Javascript">
  function showAddress(address)

          if (geocoder) 

actually, i set GeoMap variable from asp.net
the problem is that when GeoMap change value, the script does not change!
so, the button who change this value is in a UpdatePanel, does this got problem?

how can i do this?

How to write good code?


These are several general questions about writing code behind.

I already read some best practices for asp.net

The questions are:

1. Do I need to use interfaces and/or delegates for simple applications? I just cannot get in simple terms WHEN to use them. (I assume that delegates are not necessary is Asp.net, because they are by default)

2. Do we need to turn off viewstate whenever possible? Is it crucial for perfomance?

3. If I retrieve value from database on page load, how do I pass this value to other functions? For example:

protected void Page_Load(object sender, EventArgs e)
        int GameID = db.Games.Where(p => p.IsActive == true).Select(p => p.GameID).SingleOrDefault();

Do I just copy this statement to different function? for example: 

protected void Button1_Click(object sender, EventArgs e)
        int GameID = db.Games.Where(p => p.IsActive == true).Select(p => p.GameID).SingleOrDefault();

Or I use session variables for this? Or I make this Int GameID Global variable?

4. When do i need to create separate files for classes? How many events should I have? Is it crucial to use classes in separate files?

5. Is enabling/disabling/hiding controls from code b

Any better than jquery dynamically write html code?


I am creating a page which contains one grid showing the content from a very slow data source. There are other faster contents to be displayed too.

I know I can use jquery to dynamically generate the html code from a dedicated controller for the slow data source. 

However, it's not intuitive to read the jquery code for the grid. is there any better way?

How to re-write this code... Using Array instead of double[]


This is a partial piece of code that I am using and would like to re-write it so that it can use Array instead of double[].  Please assist.

Original Code

public double NormalizeValues(double[] _equivTable, double _userResult) //takes the Equivalence Tables(array) and User result(integer)

            //determine if it is a descending table 
            //For when a better score is = to a lower numbered result (i.e. running a race)
            double _linearInterpolation;

            if (_equivTable[0] > _equivTable[_equivTable.Length - 1])
                for (int i = 10; i >= 0; i--)
                    if (_userResult <= _equivTable[i])
                        if (i == 10) //This is here in case the $i_UserResult's Magnitude (Score/$aEquivTable[$iCC]) is worth a 10
                            return _linearInterpolation = 10;
                            return _linearInterpolation = LinearInterpolation(i, _equivTable, _userResult);
                return _linearInterpolation = 0; //Not Sure why this is here, but I think it is needed, in case it iterates past 0

If or Case in a LINQ SQL code, How to Use Count() Request.QueryString("imageidentity")



If i want to get some diffrent data from a DB
and its by using Request.QueryString("SortBy")

What do u use !?
If The Else or Case !?

What i want is that if SortBy in the Url link is NameUP, then its sorts by A, B C and so on
and if NameDown then the other way.

Im using this LINQ code.

    Public Sub linqdb()

        Dim DBconn As New GetProductListDataContext()
        Dim Q = _
        From p In DBconn.GetTable(Of Product)() _
        Where p.IsEnabled = "1" _
             Order By p.PName Descending _
        Select p
        Dim L = Q.ToList
        MyRep.DataSource = Q
        PValue.Text = L.Count().ToString()

    End Sub

 How do i also get this code to Count the outgoing records !?
I cant get any number from PValue.Text = L.Count().ToString()
from my CB to my .ASPX site with a <asp:Label ....

How to write JDBC code with UDT?


Exception in thread "main" com.microsoft.sqlserver.jdbc.SQLServerException: The conversion from UNKNOWN to UNKNOWN is unsupported.

      at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:171)

      at com.microsoft.sqlserver.jdbc.DataTypes.throwConversionError(

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend