Win Surprise Gifts!!!
Top 5 Contributors of the Month
Post New Question
Subscribe to Interview Questions
There is a table with name CountryTable which has only one column - CountryName. Write a query to select the name of the countries who's name repeate more than 3 times in the table.
Posted By :
Posted Date :
July 31, 2011
SELECT CountryName FROM CountryTable
GROUP BY CountryName
HAVING COUNT(*) >= 3
You can also find related Interview Question to
There is a table with name CountryTable which has only one column - CountryName. Write a query to select the name of the countries who''s name repeate more than 3 times in the table.
Write SQL Query to retrieve the employee name from emp table who are having salary greater than 5000 withoud using where Clause ?
select count(*) from tbl_name group by emp_id having salary > 5000
Write a SQL query to send mail, whenever a new record is inserted into a table using Sqlserver 2000.
Here we have to create a trigger on required table as show below.
CREATE TRIGGER SendRem
@message = 'body'
@subject = 'foo was fired.'
Would the select query below fetch any records?
create table #testvm (ID int)
select * from sysobjects where name = '#testvm'
drop table #testvm
Since temp tables are created in tempdb, and use a random name, the query will not work.
If you used a query like this, you would see your table:
select * from tempdb..sysobjects where name like '#testvm%'
How to select records from a table where some column names are duplicate and some are different ?
select * from table as A, table as B where A.field1=B.field1 and A.field2=B.field2 and A.field3<>B.field3
How To Update Description Value for a Column in Table using SQL Command?
We can Update Description to Column using sp_updateextendedproperty System Store Procedure.
Sample Command to Update Description for Column in a Table:
EXEC sys.sp_updateextendedproperty @name=N'MS_Description', @value=N'My Description for Column Here' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'MyTableName', @level2type=N'COLUMN',@level2name=N'ColumnName'
How To Delete Description Value for a Column in Table using SQL Command?
We can Delete Description from Column using sp_dropextendedproperty System Store Procedure.
Sample Command to Delete Description from Column in a Table:
EXEC sys.sp_dropextendedproperty @name=N'MS_Description', @value=N'My Description for Column Here' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'MyTableName', @level2type=N'COLUMN',@level2name=N'ColumnName'
How To Get Description Value for all Column in Table using SQL Command?
To Get Description of Columns we need to use system function sys.fn_listextendedproperty.
Command To Get Description Data for all Columns:
SELECT * FROM fn_listextendedproperty(NULL, 'SCHEMA',
'dbo', 'TABLE', 'YourTable Name Here', 'COLUMN', NULL)
How To Get Description Value for Single Column in Table using SQL Command?
To Get Description of Single Column we need to use system function sys.fn_listextendedproperty. we need to pass the column Name is this case.
Command To Get Description Data for Single Columns:
SELECT * FROM fn_listextendedproperty(NULL, 'SCHEMA',
'dbo', 'TABLE', 'Table Name Here', 'COLUMN', 'Column Name Here')
More than one IDENTITY column per table can be exist in SQL Server . (True /False)
There can only be one IDENTITY column per table in SQL Server.
Its auto Incremented Column defined by the user.
Write a query to Select top 2 Highest salaries?
select Top(2) salary from Tablename order by Salary desc....
SQL Query to find the 4th highest Value in a Table.
Let us assume that we have Table with Student Name and Mark. We have to Find out 4th highest mark from here?
SELECT TOP 1 Mark FROM
(SELECT TOP 4 Mark FROM Student ORDER BY Mark DESC) AS E
ORDER BY Mark ASC
how to find column name from sql server table?
select * from INFORMATION_SCHEMA.Columns where column_name like 'colname%'
Using query analyzer, name 3 ways to get an accurate count of the number of records in a table?
SELECT * FROM table1
SELECT COUNT(*) FROM table1
SELECT rows FROM sysindexes WHERE id = OBJECT_ID(table1) AND indid < 2
You work for a bank that uses a SQL Server 2005 database to store line items from customer banking transactions. The bank processes 50,000 transactions every day. The application requires a clustered index on the TransactionID column. You need to create a
table that supports an efficient reporting solution that queries the transactions by date.What are the two ways to achieve this goal? (Each correct answer presents a complete solution. Choose two.)
A. Place a nonclustered index on the date column.
B. Add a unique clustered index on the date column
C. Map each partition to a filegroup, with each filegroup accessing a different physical
D. Create a partitioning scheme that partitions the data by date.
Quick Links For Interview Questions Categories:
Find questions, FAQ's and their answers related to .NET, C#, Vb.Net, Sql Server and many more.
Now you can find lots of .NET, C#, Vb.Net, SQL Server,Windows, ASP.Net related Questions and their Answers here at www.dotnetspark.com. Our aim is to help you pass your certification Exams (MCP, MCSD, MCAD etc.,) with flying scores and get good name in your company.
So, Start looking our
section daily and improve your .NET Skills. You can also help others by posting Interview Questions and their Answers in this section.
Hall of Fame
Terms of Service
Tell A Friend