Showing posts with label SQL. Show all posts
Showing posts with label SQL. Show all posts

.Net Interview Questions And Answers


Home ASP.Net & C#
MVC
Others

In this blog, I will share some ideas, tutorials, Interview questions and Answers for .net Programmers. There are a lots of articles and Interview questions which I am preparing and is not completed yet. So please view the blog continuously to get all the updates :) 

Search : 

11 . What is the difference between view state and hidden field?

  • View state stores data in encrypted format, but hiddent field does not encrypt data. Because of this view state is secure but hidden field is insecure.
  • View state can store large amount of data. But hidden field store small amount of data.
12. What is an IL?
      Intermediate Language is also known as Microsoft Intermediate Language (MSIL). All the .Net source code is compiled to IL. IL is machine independent. At the time of installation only it knows in which environment it is going to install. At the point when the s/w is installed or at run time, this IL is converted to machine code by Just in Time (JIT) compiler

13. What is  JIT
      JIT stands for Just In Time compiler which is an important feature of .net. JIT converts IL to machine code at the time of installation of the software or at runtime.

14. What is Assembly Manifest ?
       Assembly metadata is stored in Manifest. Manifest contains the flollowing things.
  • Version of assembly.
  • Scope of the assembly
  • Security information.
  • References to other assemblies and classes
15. What is the difference between Primary key and unique key?
  • Primary key does not allow nulls. But unique key allow one null value in the column.
  • By Default primary key creates clustered index on the column but unique key creates a non clustered index by default.
16.  What is the difference between .toString() and Convert.toString()?
       
       .toString() does not handle nulls. But Convert.toString() handle null and return empty but .toString() will throw null reference exception if null value comes. So as a good practice it is better to use Convert.toString()

17. What is meant by page rendering ?
      Page rendering is nothing but just converting the .aspx (server) controls to HTML controls for sending it to client browser.

18. What is boxing and unboxing in .net?
      Boxing is the process of converting value type to reference type. Unboxing is the process of converting reference type to value type

19. Can we force garbage collector to run ?

      Yes. We can do this by System.GC.Collect();

20. How Can I block finally block to be executed after the try block?
      
      Use System.exit (0); at the end of try block. It will make the control to go outside the executing program. And the finally block will not get executed.



Dot Net Concepts and Interview Questions

How To split a string in SQL Server

SQL Function For Spliting a String in SQL SERVER

In SQL Server we do not have a built in function for splitting a string with any character. So we need to write the query for splitting a string in SQL. Here I am creating a function for splitting a string and getting the output data in a table.

CREATE FUNCTION [dbo].[fnSplitString] ( @MyArray VARCHAR(8000), @separator CHAR(1) )
RETURNS @RetTable TABLE
       (StrValue VARCHAR(256))
AS

BEGIN
       DECLARE @SeperatorString VARCHAR(10);
       SET @SeperatorString = '%' + @separator + '%'
       DECLARE @separator_position INT
       DECLARE @array_value VARCHAR(1000)
       SET @MyArray = @MyArray + @separator
       WHILE PATINDEX( @SeperatorString , @MyArray) <> 0
       BEGIN
              SELECT @separator_position =  PATINDEX(@SeperatorString , @MyArray)
              SELECT @array_value = LEFT(@MyArray, @separator_position - 1)
              INSERT @RetTable VALUES ( CAST(@array_value AS VARCHAR(256)) )
              SELECT @MyArray = STUFF(@MyArray, 1, @separator_position, '')
       END

       RETURN
END

This will create a new function. Now you can easily pass parameters to this function and get the data in a table format. Parameters are
@MyArray   - The full string which we need to split
@separator - The character by which we need to split
Here are some examples
Example 1 :
SELECT StrValue FROM dbo.[fnSplitString]('data1,data2,data3,data4',',')
The result will be

Here the separator is comma( , ).

Example 2 :

DECLARE @MyString VARCHAR(1000);
SET @MyString = 'data1;data2;data3;data4;1;2;3'
SELECT StrValue FROM dbo.[fnSplitString](@MyString,';')
 The result will be

Here the separator is semi-column(;)

Thanks for reading my post. Happy Coding. :)