Enter your keyword

post

STRING DATA TYPES

Definition


A string is a data type used in programming, such as an integer and floating point unit, but is used to represent text rather than numbers. It is comprised of a set of characters that can also contain spaces and numbers. For example, the word “hamburger” and the phrase “I ate 3 hamburgers” are both strings. Even “12345” could be considered a string, if specified correctly. Typically, programmers must enclose strings in quotation marks for the data to recognized as a string and not a number or variable name.

Example

using System;
using System.Data.SqlClient;

class Program
{
static void Main()
{
//
// First access the connection string.
// ... This may be autogenerated in Visual Studio.
//
string connectionString =
ConsoleApplication1.Properties.Settings.Default.ConnectionString;
//
// In a using statement, acquire the SqlConnection as a resource.
//
using (SqlConnection con = new SqlConnection(connectionString))
{
//
// Open the SqlConnection.
//
con.Open();
//
// The following code uses an SqlCommand based on the SqlConnection.
//
using (SqlCommand command = new SqlCommand("SELECT TOP 2 * FROM Dogs1", con))
using (SqlDataReader reader = command.ExecuteReader())
{
while (reader.Read())
{
Console.WriteLine("{0} {1} {2}",
reader.GetInt32(0), reader.GetString(1), reader.GetString(2));
}
}
}
}
}

Commonly asked interview questions on Constructors

1.This set of SQL Server Multiple Choice Questions & Answers (MCQs) focuses on “Data Types”.

Answer :1. Which of the followig is large object data type ?
a) varchar(max)
b) varbinary(max)
c) nvarchar(max)
d) image
Answer: d
Explanation: In SQL Server, based on their storage characteristics, some data types are designated as large value data types and large object data types.

2. Data types in SQL Server are organized into how many categories ?

Answer :It includes −

a) 6
b) 8
c) 9
d) 10
Answer: a
Explanation: SQL Server offers six categories of data types for your use:-exact numeric , Unicode character strings, approximate numeric , Binary strings, Date and time and Character strings.

3. Exact Numeric data type is __________.

Answer :
a) bigint
b) int
c) smallmoney
d) All of the mentioned
Answer: d
Explanation: Exact numeric data types store numeric values where you wish to specify the precision of the variable. They may include integer or decimal numbers.

4. ntext datatype falls under which category ?

Answer :
a) Exact numerics
b) Character strings
c) Unicode character strings
d) None of the mentioned
Answer: c
Explanation: ntext is fixed and variable-length data type for storing large non-Unicode and Unicode character.

5. Which of the the following data type is not present in SQL Server ?

Answer :
a) bit
b) boolean
c) hierarchyid
d) geography
Answer: b
Explanation: SQL Server doesn’t have a Boolean data type, at least not by that name. To store True/False, Yes/No, and On/Off values, use the bit data type. It accepts only three values: 0, 1, and NULL.

Take Sample Test

Reference Books


1. Head First Java

No Comments

Add your review

Your email address will not be published.