0% found this document useful (0 votes)
126 views17 pages

ERP Short Questions

The document provides answers to various short questions about C# web development, ASP.NET, and ADO.NET. It includes questions and answers related to connection strings, SqlCommands, data adapters, datatables, gridviews, dropdownlists, loops, redirects, sessions, and more. Key topics covered are connecting to databases, filling datatables from commands, binding datatables to controls, and retrieving values from controls in gridview rows, footers, and headers.

Uploaded by

hassancheema36
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
126 views17 pages

ERP Short Questions

The document provides answers to various short questions about C# web development, ASP.NET, and ADO.NET. It includes questions and answers related to connection strings, SqlCommands, data adapters, datatables, gridviews, dropdownlists, loops, redirects, sessions, and more. Key topics covered are connecting to databases, filling datatables from commands, binding datatables to controls, and retrieving values from controls in gridview rows, footers, and headers.

Uploaded by

hassancheema36
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 17

Short Questions C# web:

What is the connection string in asp.net Model page with server? Ans. SqlConnection conn = new SqlConnection ("Data Source=(local)\\SQLEXPRESS;Database=sunny;Integrated Security=true"); How command string is created in asp.net Model page? Ans. SqlCommand comm = new SqlCommand(); How to tell the command object which connection he will use? Ans. comm.Connection = conn; Which method is used to open and close a connection? Ans. Conn.Open(); Conn.Close(); How to fill data adapter from select command? Ans. SqlDataAdapter da = new SqlDataAdapter(); da.SelectCommand = new SqlCommand(); da.SelectCommand.Connection = conn; conn.Open(); da.SelectCommand.CommandText = "SELECT TEACHER_NAME FROM tblTeacher; conn.Close(); How to fill DataTable from the data adapter object? Ans. DataTable dt = new DataTable(); da.Fill(dt); How to fill DataSet from the data adapter object? Ans. DataSet ds = new DataSet(); da.Fill(ds,DataTable1); How to clear text in a textbox? Ans.TextBox1.Text = ;

How can we set the Focus on a control in ASP.NET? Ans. TextBox1.Focus(); OR Page.SetFocus(TextBox1); How to bind datatable in Gridview? Ans. DataTable dt = new DataTable(); GridView1.DataSource = dt; GridView1.DataBind(); How to add new row in Gridview? Ans. GridView1.Rows.Add(zeeshan,23,25101-9865467-1); How to get TextBox text from Gridviews Footer? Ans. ((TextBox)GridView1.FooterRow.FindControl("TextBox1")).Text; How to get Label text from Gridviews Footer?

Ans. ((Label)GridView1.FooterRow.FindControl("Label1")).Text; How to get Dropdownlist Selected text from Gridviews Footer? Ans. ((DropDownList)GridView1.FooterRow.FindControl(DropDownList1")).SelectedIem.Te xt; OR ((DropDownList)GridView1.FooterRow.FindControl(DropDownList1")).SelectedText; How to get Dropdownlist Selected value from Gridviews Footer? Ans. ((DropDownList)GridView1.FooterRow.FindControl("DropDownList1")).SelectedIem.Va lue; OR ((DropDownList)GridView1.FooterRow.FindControl("DropDownList1")).SelectedValue; How to get TextBox text from Gridviews Header? Ans. ((TextBox)GridView1.HeaderRow.FindControl("TextBox1")).Text; How to get Label text from Gridviews Header? Ans. ((Label)GridView1.HeaderRow.FindControl("Label1")).Text; How to get Dropdownlist Selected text from Gridviews Header? Ans. ((DropDownList)GridView1.HeaderRow.FindControl(DropDownList1")).SelectedIem.Te xt; OR ((DropDownList)GridView1.HeaderRow.FindControl(DropDownList1")).SelectedText; How to get Dropdownlist Selected value from Gridviews Header? Ans. ((DropDownList)GridView1.HeaderRow.FindControl("DropDownList1")).SelectedIem.Va lue; OR ((DropDownList)GridView1.HeaderRow.FindControl("DropDownList1")).SelectedValue; How to get TextBox text from Gridviews Row or Item Row? Ans. ((TextBox)GridView1.Row[rowno/index].FindControl("TextBox1")).Text; How to get Label text from Gridviews Row or Item Row? Ans. ((Label)GridView1.Row[rowno/index].FindControl("Label1")).Text; How to get Dropdownlist Selected text from Gridviews Row or Item Row? Ans. ((DropDownList)GridView1.Row[rowno/index].FindControl(DropDownList1")).Selecte dIem.Text; OR ((DropDownList)GridView1.Row[rowno/index].FindControl(DropDownList1")).Selecte dText; How to get Dropdownlist Selected value from Gridviews Row or Item Row? Ans. ((DropDownList)GridView1.Row[rowno/index]FindControl("DropDownList1")).Selected Iem.Value; OR

((DropDownList)GridView1.Row[rowno/index].FindControl("DropDownList1")).Selecte dValue;

How to bind datatable in Dropdownlist? Ans. DataTable dt = new DataTable(); DropDownList1.DataSource = dt; DropDownList1.DataTextField = "CAMPUS_NAME"; DropDownList1.DataValueField = "CAMPUS_ID"; DropDownList1.DataBind(); How to add new item in dropdownlist using list item? Ans. ListItem li = new ListItem("Campus", "0"); DropDownList1.Items.Add(li); How to select a particular Index in Dropdownlist? Ans. DropDownList1.SelectedIndex = 2; How to select a particular Text in Dropdownlist? Ans. DropDownList1.SelectedIndex = DropDownList1.Items.IndexOf(DropDownList1.Items.FindByText(Lahore)); How to select a particular Value in Dropdownlist? Ans. DropDownList1.SelectedIndex = DropDownList1.Items.IndexOf(DropDownList1.Items.FindByValue(IT)); How to get selected Value from Dropdownlist? Ans. int a = DropDownList1.SelectedItem.Value; OR Int a = DropDownList1.SelectedValue; How to get selected Value from Dropdownlist? Ans. String a = DropDownList1.SelectedItem.Text; OR String a = DropDownList1.SelectedText; What is the syntax of Do While Loop? Ans. int JuiceQty=0; do{ MessageBox.Show( + JuiceQty + ); JuiceQty+1; } While(JuiceQty<5); What is the syntax of While Loop? Ans. int JuiceQty=0; While(JuiceQty<5) { MessageBox.Show( + JuiceQty + ); JuiceQty+1; } What is the syntax of For Loop? Ans. for (int i = 0; i < 5; i++) {

} How to show alert message? Ans. ScriptManager.RegisterStartupScript(this, this.GetType(), "", "alert('Saved Successfully!')", true);

Which method is used to redirect the user to another page without performing a round trip to the client? Ans. Server.Transfer("Main.aspx"); method How to redirect to a new page? Ans. Response.Redirect("Main.aspx"); How to write or display a text message? Ans. Response.Write("UserName or Password is Invalid!!"); What is the syntax of Switch Statement? Ans. String gender=MiddleSex; switch( gender ) { case Male: MessageBox.Show(gender is Male); break; case Female : MessageBox.Show(gender is Male); break; case MiddleSex : MessageBox.Show(gender is Male); break; } What is the syntax of Try Catch block? try { //Lines of code return true; } catch (Exception e) { return false; } What is the syntax of Try Catch and finally block? try { //Lines of code } catch (Exception e) { return false; } Finally

//Lines of code } How to count rows in a datatable? Ans. dt.Rows.Count; How to add value in ViewState? Ans. ViewState["Name"] = Zeeshan; How to add value in Session? Ans. Session["Name"] = Zeeshan; How to get value from ViewState? Ans. String a = (String)ViewState["Name"]; How to get value from Session? Ans. String a = (String)Session["Name"]; How to we add customized columns in a Gridview in ASP.NET? Ans. Make use of the TemplateField column. Is it possible to stop the clientside validation of an entire page? Ans. Set Page.Validate = false; Is it possible to disable client side script in validators? Ans. Yes. simply EnableClientScript = false. How do we enable tracing in .NET applications? Ans. <%@ Page Trace=true %> How to kill a user session in ASP.NET? Ans. Use the Session.abandon() method. What are the steps to use a checkbox in a gridview? Ans. <TemplateField><ItemTemplate> <asp:CheckBox id=CheckBox1 runat=server AutoPostBack=True></asp:CheckBox> </ItemTemplate></TemplateField>

____________________________________________________________________________________

Short Questions Dot.Net:


What is garbage Collection? Ans. Garbage collection (GC) is a form of automatic memory management. The garbage collector or collector attempt to collect garbage Such as free/unused memory occupied by those objects which are no longer in use by the program. What is FCL? Ans. The FCL is a collection of over 7000 classes and data types that enable .NET applications to read and write files, access databases, process XML, display a graphical user interface, draw graphics, use Web services etc. Is FCL is similar to that of BCL? Ans. Yes they both are exactly the same. Framework class library is sometime also known as Base Class library i.e. Base Class Library.

What is Deployment? Ans. Software deployment is all of the activities that make a software system

available for use


What is Configuration? Ans. Configuration involves everything from application settings such as database connections to security details and information about how errors should be handled. Configuration files provide a location for computer-specific and application-specific information that you can change without having to recompile code. What is C#.net? Ans. C# is designed to be a platform-independent language in the tradition of Java. Its syntax is similar to C and C++ syntax, and C# is designed to be an object-oriented language. There are, for the most part, minor variations in syntax between C++ and C#. What is VB.net and how it differs from old VB (Visual Basic)? Ans. While Differencing between VB and VB.NET. There is not much in common between VB and VB.NET other than the name. VB.NET is a totally new programming language. It just retains the syntax of old VB. So, if you are a VB programmer, probably you may like VB.NET than C# just because of the syntax. Who has better performance VB.net or C#.net? Ans. Whether you write code in VB.NET or C# or in any other dot .Net supported language, when you compile, your code will get converted to MSIL (Microsoft Intermediate language). The MSIL is then executed by the same .NET framework, whether you wrote it originally in C# or VB.NET. The MSIL generated by C# and VB.NET is almost 99% same and performance is exactly the same! What is ADO.Net? Ans. ADO.NET is an object-oriented set of libraries that allows you to interact with data sources. Commonly, the data source is a database (Microsoft SQL Server, Microsoft Access, Oracle etc), but it could also be a text file, an Excel spreadsheet, or an XML file. Name Various objects of ADO.net? Ans. SqlConnection Object SqlCommand Object SqlDataReader Object SqlDataAdapter Object Dataset Object Response.Redirect: This tells the browser that the requested page can be found at a new location. The browser then initiates another request to the new page loading its contents in the browser. This results in two requests by the browser. Server.Transfer: It transfers execution from the first page to the second page on the server. As far as the browser client is concerned, it made one request and the initial page is the one responding with content. The benefit of this approach is one less round trip to the server from the client browser. Also, any posted form variables and query string parameters are available to the second page as well. What is CLR?

Common Language Runtime (CLR) is a run-time environment in dot.net framework that manages the execution of .NET code and provides services like memory management, debugging, security, etc. The CLR is also known as Virtual Execution System (VES). What is CLI (Common language Infrastructure)? The CLI is a set of specifications including a common type system, base class library, and a machineindependent intermediate code known as the Common Intermediate Language (CIL). List the various stages of Page-Load lifecycle. o o o o Init() Load() PreRender() Unload()

What is DLL Hell? DLL hell is the problem that occurs when an installation of a newer application might break or hinder other applications as newer DLLs are copied into the system and the older applications do not support or are not compatible with them. .NET overcomes this problem by supporting multiple versions of an assembly at any given time. This is also called side-by-side component versioning. What is CLS? Ans. This is a subset of the CTS which all .NET languages are expected to support. It was always a dream of Microsoft to unite all different languages in to one umbrella and CLS is one step towards that. Microsoft has defined CLS which are nothing but guidelines that language to follow so that it can communicate with other .NET languages in a seamless manner. Explain Windows Forms. Windows Forms is employed for developing Windows GUI applications (Desktop Applications). It is a class library that gives developers access to Windows Common Controls with rich functionality. It is a common GUI library for all the languages supported by the .NET Framework. List the ASP.NET validation controls? o RequiredFieldValidator

o o o o o

RangeValidator CompareValidator RegularExpressionValidator CustomValidator ValidationSummary

What is Data Binding? Data binding is a way used to connect values from a collection of data (e.g. DataSet) to the controls on a web form. The values from the dataset are automatically displayed in the controls without having to write separate code to display them. For example Databinding in gridview and dropdownlist etc. Should user input data validation occur server-side or client-side? Why? All user input data validation should occur on the server and minimally on the client-side, though client side validation is a good way to reduce server load and network traffic because we can ensure that only data of the appropriate type is submitted from the form. It is totally insecure. The user can view the code used for validation and create a workaround for it. Secondly, the URL of the page that handles the data is freely visible in the original form page. What is Intermediate Language? Ans. C#, as part of the .NET framework, is compiled to Microsoft Intermediate Language (MSIL), which is a language similar to Java's Byte code. Furthermore, because the other languages that used the .NET platform (including VB.net and C++) compile to MSIL, it is possible for classes to be inherited across Languages and communicate with one another. What is Code-Behind? Code-Behind is a concept where the contents(buttons,textboxes etc) of a page are in one file and the server-side code is in another. This allows different people to work on the same page at the same time and also allows either part of the page to be easily redesigned, with no changes required in the other. Describe the difference between inline and code behind. Inline code is written along side the HTML in a page. There is no separate distinction between design code and logic code. Code-behind is code written in a separate file.

What is the difference between client side and server side code? Ans. Server side code will execute at server end (where the website is hosted or configured) and all the business logic will execute at server end where as Client side code will execute at client side that is at browser end (usually written in javascript, vbscript, jscript). What is CTS? Ans. In order that two languages communicate smoothly CLR has CTS (Common Type System). In order that two different languages can communicate. Microsoft introduced Common Type System. The CTS defines/specify all possible data types supported by the CLR and how they may or may not interact with each other. What type of code (server or client) is found in a Code-Behind class? Ans. Server side code. How to make sure that value is entered in an asp:Textbox control? Ans. Use a RequiredFieldValidator control. Which property of a validation control is used to associate it with a server control on that page? Ans. ControlToValidate property. Which method is invoked on the DataAdapter control to load the generated dataset with data? Ans. Fill() method. What method is used to explicitly kill a users session? Ans. Session.Abandon() What property within the asp:gridview control is changed to bind columns manually? Ans. Autogenerated columns is set to false Which method is used to redirect the user to another page without performing a round trip to the client? Ans. Server.Transfer method. How many ways can we maintain the state of a page? Ans. 1. Client Side Query string, hidden variables, viewstate, cookies 2. Server side application , cache, context, session, database Will the finally block be executed in try catch if an exception has not occurred? Ans. Yes it will execute. What is a Dataset? Ans. A dataset is an in memory database kind of object that can hold database information in a disconnected environment. Is XML a case-sensitive markup language? Ans. Yes. What is Overloading? Ans. Overloading enables method to be defined with the same name but with different parameters. In other words it allows you to have multiple implementations of a method.

What is Overriding? Ans. Overriding is the capability of a class to override the characteristic/function of the parent class. Are MSIL and CIL the same thing? Ans. Yes, CIL is the new name for MSIL. What is the base class of all web forms? Ans. System.Web.UI.Page How to add a client side event to a server control? Ans. Example Button1.Attributes.Add(onclick,javascript:SomeFunctionInJavascript()); Can a single .NET DLL contain multiple classes? Ans. Yes, a single .NET DLL may contain any number of classes within it. What is DLL Hell? Ans. DLL Hell is the name given to the problem of old unmanaged DLLs due to which there was a possibility of version conflict among the DLLs. can we put a break statement in a finally block? Ans. The finally block cannot have the break, continue, return and go to statements. Can we run ASP.NET 1.1 application and ASP.NET 2.0 application on the same computer? Ans. Yes, though changes in the IIS in the properties for the site have to be made during deployment of each. Can we pop a MessageBox in a web application? Ans. Yes, though this is done clientside using an alert, prompt or by opening a new web page that looks like a messagebox. What is managed data? Ans. The data for which the memory management is taken care by .Net runtimes garbage collector. How to instruct the garbage collector to collect unreferenced data? Ans. We may call the garbage collector to collect unreferenced data by executing the System.GC.Collect() method. Can we force the garbage collector to run? Ans. Yes, using the System.GC.Collect(), the garbage collector is forced to run in case required to do so. What is Code Access security? What is CAS in .NET? Ans. CAS is the feature of the .NET security model that determines whether an application or a piece of code is permitted to run and decide the resources it can use while running. What is Multi-tasking? Ans. It is a feature of operating systems through which multiple programs may run on the operating system at the same time, just like a scenario where a Notepad, a Calculator and the Control Panel are open at the same time. What is Multi-threading? Ans. When an application performs different tasks at the same time, the application is said to exhibit

multithreading as several threads of a process are running. What is a Thread? Ans. A thread is an activity started by a process and its the basic unit to which an operating system allocates processor resources. How can we force a thread to sleep for an infinite period? Ans. Call the Thread.Interupt() method. What is Suspend and Resume in .NET Threading? Ans. Just like a song may be paused and played using a music player, a thread may be paused using Thread.Suspend() method and may be started again using the Thread.Resume() method. What is Ajax? Ans. Asyncronous Javascript and XML Ajax is a combination of client side technologies that sets up asynchronous communication between the user interface and the web server so that partial page rendering occur instead of complete page postbacks. What is XmlHttpRequest in Ajax? Ans. It is an object in Javascript that allows the browser to communicate to a web server asynchronously without making a postback. What are the different modes of storing an ASP.NET session? Ans. InProc (the session state is stored in the memory space of the Aspnet_wp.exe process but the session information is lost when IIS reboots), StateServer (the Session state is serialized and stored in a separate process call Viewstate is an object in .NET that automatically persists control setting values across the multiple requests for the same page and it is internally maintained as a hidden field on the web page though its hashed for security reasons. How to prevent overriding of a class in .NET? Ans. Use the keyword NotOverridable in VB.NET and sealed in C#. How to prevent inheritance of a class in .NET? Ans. Use the keyword NotInheritable in VB.NET and sealed in C#. What does the virtual keyword in C# mean? Ans. The virtual keyword signifies that the method and property may be overridden. Is it possible to have have different access modifiers on the get and set methods of a property in .NET? Ans. No we can not have different modifiers of a common property, which means that if the access modifier of a propertys get method is protected, and it must be protected for the set method as well. In .NET, is it possible for two catch blocks to be executed in one go? Ans. This is NOT possible because once the correct catch block is executed then the code flow goes to the finally block. What technique is used to figure out that the page request is a postback? Ans. The IsPostBack property of the page object may be used to check whether the page request is a postback or not. IsPostBack property is of the type Boolean. Which event of the ASP.NET page life cycle completely loads all the controls on the web page?

Ans. The Page_load event of the ASP.NET page life cycle assures that all controls are completely loaded. Even though the controls are also accessible in Page_Init event but here, the viewstate is incomplete. What is the ValidationSummary control in ASP.NET used for? Ans. The ValidationSummary control in ASP.NET displays summary of all the current validation errors. What is AutoPostBack feature in ASP.NET? Ans. In case it is required for a server side control to postback when any of its event is triggered, then the AutoPostBack property of this control is set to true. AutoPostBack Property of a button is true by default. What is the difference between Web.config and Machine.Config in .NET? Ans. Web.config file is used to make the settings to a web application, whereas Machine.config file is used to make settings to all ASP.NET applications on a server (the server machine. What is the difference between a session object and an application object? Ans. A session object can persist information in whole application for a particular user, whereas an application object can be used globally for all the users. How to we add customized columns in a Gridview in ASP.NET? Ans. Make use of the TemplateField column. Is it possible to stop the clientside validation of an entire page? Ans. Set Page.Validate = false; Is it possible to disable client side script in validators? Ans. Yes. simply EnableClientScript = false. How do we enable tracing in .NET applications? Ans. <%@ Page Trace=true %> How to kill a user session in ASP.NET? Ans. Use the Session.abandon() method. What are the steps to use a checkbox in a gridview? Ans. <TemplateField><ItemTemplate> <asp:CheckBox id=CheckBox1 runat=server AutoPostBack=True></asp:CheckBox> </ItemTemplate></TemplateField> What is difference between dataset and datareader in ADO.NET? Ans. A DataReader provides a forward-only and read-only access to data, while the DataSet object can carry more than one table and at the same time hold the relationships between the tables. You can also modify data in the DataSet object. Also note that a DataReader is used in a connected architecture whereas a Dataset is used in a disconnected architecture. Can connection strings be stored in web.config? Ans. Yes, in fact this is the best place to store the connection string information. Whats the difference between web.config and app.config? Ans. Web.config is used for web based asp.net applications whereas app.config is used for windows based applications.

Short Questions Database: What is a query? A query is a request for information from a database. What is the purpose of the model database in Sql Server? It works as Template Database for the Create Database Syntax What is the purpose of the master database Sql Server? Master database keeps the information about sql server configuration, databases users etc What is the purpose of the tempdb database Sql Server? Tempdb database keeps the information about the temporary objects (#TableName, #Procedure). Also the sorting, DBCC operations are performed in the TempDB What is the purpose of the USE command? Use command is used for to select the database. That is Use DBJuiceShop If you delete a table in the database, will the data in the table be deleted too? Yes What is the Parse Query button used for? How does this help you? Parse query button is used to check the SQL Query Syntax What is usually the first word in a SQL query? SELECT What is the ORDER BY used for? Order By clause is used for sorting records in Ascending or Descending order Does ORDER BY actually change the order of the data in the tables or does it just change the output? Order By clause change only the output of the data What is the default order of an ORDER BY clause? Ascending Order What kind of comparison operators can be used in a WHERE clause?
Operator = (Equals) Equal to Meaning

> (Greater Than) < (Less Than) >= (Greater Than or Equal To) <= (Less Than or Equal To) <> (Not Equal To) != (Not Equal To) !< (Not Less Than) !> (Not Greater Than)

Greater than Less than Greater than or equal to Less than or equal to Not equal to Not equal to (not SQL-92 standard) Not less than (not SQL-92 standard) Not greater than (not SQL-92 standard)

What are four major operators that can be used to combine conditions on a WHERE clause? OR, AND, IN and BETWEEN What are the logical operators?
Operator ALL AND ANY BETWEEN EXISTS IN LIKE NOT OR SOME Meaning TRUE if all of a set of comparisons are TRUE. TRUE if both Boolean expressions are TRUE. TRUE if any one of a set of comparisons are TRUE. TRUE if the operand is within a range. TRUE if a subquery contains any rows. TRUE if the operand is equal to one of a list of expressions. TRUE if the operand matches a pattern. Reverses the value of any other Boolean operator. TRUE if either Boolean expression is TRUE. TRUE if some of a set of comparisons are TRUE.

In a WHERE clause, do you need to enclose a text column in quotes? Do you need to enclose a numeric column in quotes? Enclose Text in Quotes (Yes) Enclose Number in Quotes (NO) Is a null value equal to anything? Can a space in a column be considered a null value? Why or why not? No NULL value means nothing. We cant consider space as NULL value. Will COUNT(column) include columns with null values in its count? Yes, it will include the null column in count What are column aliases? Why would you want to use column aliases? How can you embed blanks in column aliases? You can create aliases for column names to make it easier to work with column names, calculations, and summary values. For example, you can create a column alias to: * Create a column name, such as Total Amount, for an expression such as (quantity * unit_price) or for an aggregate function. What are table aliases? Aliases can make it easier to work with table names. Using aliases is helpful when: * You want to make the statement in the SQL shorter and easier to read. * You are working with multiple instances of the same table (such as in a self-join) and need a way to refer to one instance or the other. Are semicolons required at the end of SQL statements in SQL Server? No it is not required Is SQL case-sensitive? Is SQL Server 2005 case-sensitive? No both are not case-sensitive. While you are inserting values into a table with the INSERT INTO .. VALUES option, does the order of the columns in the INSERT statement have to be the same as the order of the columns in the table? Not Necessary While you are inserting values into a table with the INSERT INTO .. SELECT option, does the order of the columns in the INSERT statement have to be the same as the order of the columns in the table? Yes if you are not specifying the column names in the insert clause, you need to maintain the column order in SELECT statement

What does the UPDATE command do? Update command will modify the existing record Can you change the data type of a column in a table after the table has been created? If so, which command would you use? Yes we can. Alter Table Modify Column OR write click the table and select Design to modify Will SQL Server allow you to reduce the size of a column? Yes it allows What is the default value of an integer data type in SQL Server? NULL What is the difference between a CHAR and a VARCHAR datatype? CHAR and VARCHAR data types are both non-Unicode character data types with a maximum length of 8,000 characters. The main difference between these 2 data types is that a CHAR data type is fixed-length while a VARCHAR is variable-length. If the number of characters entered in a CHAR data type column is less than the declared column length, spaces are appended to it to fill up the whole length. Does Server SQL treat CHAR as a variable-length or fixed-length column? SQL Server treats CHAR as fixed length column If you are going to have too many nulls in a column, what would be the best data type to use? Variable length columns only use a very small amount of space to store a NULL so VARCHAR datatype is the good option for null values. When columns are added to existing tables, what do they initially contain? The column initially contains the NULL values What is a constraint? Constraints in Microsoft SQL Server allow us to define the ways in which we can automatically enforce the integrity of a database. What does the NOT NULL constraint do? Constrain will not allow NULL values in the column What is a concatenated primary key? Each table has one and only one primary key, which can consist of one or many columns. A concatenated primary key comprises two or more columns. What is a candidate key?

In a single table, you might find several columns, or groups of columns, that might serve as a primary key and are called candidate keys. A table can have more than one candidate key, but only one candidate key can become the primary key for that table. How are the UNIQUE and PRIMARY KEY constraints different? A UNIQUE constraint is similar to PRIMARY key, but you can have more than one UNIQUE constraint per table. What is a foreign key? FOREIGN KEY constraints identify the relationships between tables. A foreign key in one table points to a candidate key/Primary key in another table.

You might also like