Sql Server Interview Questions and Answers (1758) - Page 57

What is the difference between below queries? Select * from table_name order by primary_key_id desc; Select * from table_name order by 1 desc;

Both will return the same result by applying descending order.
Generally we give Id as a primary key field which is by-default numeric value and 1 is also numeric value.That is the reason we get same record with bot the queries.
How to see all the tables(UDT) from within all DB in My-SQL database?

MySQL DB has Show Tables in-build command which extracts all the table from all the Databases.
It's very simple to see all the User Defined Tables.

For Example:-
Show Tables;

How to see all the User Defined Tables from specific DB in My-SQL database?

We will write Show Tables From DB_Name in query window to get Tables from within specific Database.

Syntax:-
Show Tables From DB_Name;

What is an alternative way of getting tables in MY-Sql Database?

We can use information_schema.tables view to get all the tables in specified database.

For Example:-
select table_name as 'Udt Tables' from information_schema.tables

where table_schema = 'db_name';

When we write more than one columns in a Select statement,then which character is used to separate column names?

NOTE: This is objective type question, Please click question title for correct answer.
Which one is the correct order in a SELECT statement?

NOTE: This is objective type question, Please click question title for correct answer.
Which of the following is not a SQL transaction statement?

NOTE: This is objective type question, Please click question title for correct answer.
Which of the following function is a SQL aggregate function?

NOTE: This is objective type question, Please click question title for correct answer.
Which of the following function is a SQL Mathematical function?

NOTE: This is objective type question, Please click question title for correct answer.
Which of the following is a valid way to add comments to a SQL statement?

NOTE: This is objective type question, Please click question title for correct answer.
Which of the following is a valid way to add multi-line comments to a SQL statement?

NOTE: This is objective type question, Please click question title for correct answer.
how to copy data from one table to another table in another database

select * into desti.dbo.new from sourc.dbo.table;

here in above query
desti means name of the database where you want to create new table.
new means name of the new table in which you copy the data.
source means name of the database from where your table is located.

table means name of the table from which you take the data for copying.
dbo means database object
What will be the output of the following Select statement? select 2000/02/25 + 4

NOTE: This is objective type question, Please click question title for correct answer.
What will be the result? select STR(938.56,6,1);

NOTE: This is objective type question, Please click question title for correct answer.
What will be the value of the @Bit variable in below statement? declare @val bit; set @val = -1; select @val as Output;

NOTE: This is objective type question, Please click question title for correct answer.
What is the use IsNumeric function?

IsNumeric is an in-built Sql Server function which is used for checking valid Numeric values.

Syntax:-
Isnumeric(integer_value);

For Example:-
Select Isnumeric('12345') As Output1

Select Isnumeric(4567) As Output2

Output:
1

Found this useful, bookmark this page to the blog or social networking websites. Page copy protected against web site content infringement by Copyscape

 Interview Questions and Answers Categories