SQL Guff

Archived from the original Sajha.com — preserved as posted, replies can no longer be added here.
Start a New Discussion
Archived Post

I just want to give answer to first question right now select Top 1 T.Number from (select top 3 Number from NumberTable order by Number desc) T order by T.Number asc

virusno1 · Jan 6, 2009 11:27 AM · 20,871 views

8 Replies

Now here is a lil Tricky Question Suppose You have only Database Name. You don't know about table and the column field and datatype. Suppose You want to find a word called "sajha" in one of the table in that database. You don't know in which table and in which column. You know only Database Name. Now how do you find it. You can use any SQL commands(Cursors, Store eproc, Assemblies whatever). Lets do this Sajha SQL guys. have fun :)

virusno1 · Jan 6, 2009 11:37 AM

Hello Here is solution: a) How to find the 3rd largest value from a column ( not using stor proc) ? - first you pick top 3 value from column  with desc order - pick top 1 from above  with asc order In AdventureDatabase to  get Third ListPrice SELECT TOP 1 T.ListPrice FROM (SELECT DISTINCT TOP 3 ListPrice FROM Production.Product ORDER BY ListPrice DESC )T ORDER BY T.ListPrice ASC b) Difference between index hint and table hint. Table hints override the default behavior of the query optimizer for the duration of the data manipulation language (DML) statement by specifying a locking method, one or more indexes, a query processing operation such as a table scan or index seek, or other options c) Dynamic Queries and Static Queries. - SQ gives always same value while DQ gives different value on Execution. You can take a simple example. when you make a condition like name = "stylish" it gives fixed result but when you pass some @name parameter it gives differnt value( this is just simple ex) d) Whats the difference between using set and select for setting the value inside the stored procedure. SET can only assign one variable at a time, SELECT can make multiple assignments at once e) How do you call the nested stored procedure? i dont have exact example right now but here is a link ,i found for you. http://www.sqlservercentral.co...   hopefully, i will help you.. all the best          

rawbee · Jan 6, 2009 12:07 PM

What is the difference between Clustered Index and Unique Clustered Index?

Maayakobarima · Jan 6, 2009 12:49 PM

1)  Select  t.ItemList from      (Select Rownumber( ) over (order by ItemList desc) as Seq, Itemlist from table)t      Where t.seq =3

smoothcriminal · Jan 6, 2009 12:50 PM

Non-Unique Clustered Index - Clustered index with Non unique value Unique Clustered Index - Clustered Index with Unique value like primary Key,

smoothcriminal · Jan 6, 2009 12:53 PM

What is difference between covering index and covering query?

Maayakobarima · Jan 6, 2009 1:56 PM

Virus No 1 Here is your Solution CREATE PROC [dbo].[spUtil_Occur] (     @SearchString SQL_VARIANT ) As /**************************************************************************** *Procedure Name: spUtil_Occurences *Author:        Pat Reddy *Purpose:    This procedure is useful for finding field and/or table references.                 It will search the entire database. Best of all, if you create a key stroke shortcut                 to execute the proc, you can highlight any text in your editor and search for it instantly.                 And because the proc's only parameter is of type SQL_VARIANT, there's no need to                 surround the input parameter with single quotes!                                  Feel free to contact me with any questions at all:                 Pat Reddy - Reddy Software Solutions at:        reddys@charter.net *By the way, I cannot take full credit for this script as I found it somewhere years ago and merely modified it to my liking. ******************************************************************************/ SET NOCOUNT ON DECLARE @SQL VARCHAR(1500) SELECT @SQL = 'SELECT SUBSTRING(SO.name, 1, 40 ) as Object, COUNT(*) as Occurences, ' + 'CASE ' + ' WHEN SO.xtype = 'D' THEN 'Default' ' + ' WHEN SO.xtype = 'F' THEN 'Foreign Key' ' + ' WHEN SO.xtype = 'P' THEN 'Stored Procedure' ' + ' WHEN SO.xtype = 'PK' THEN 'Primary Key' ' + ' WHEN SO.xtype = 'S' THEN 'System Table' ' + ' WHEN SO.xtype = 'TR' THEN 'Trigger' ' + ' WHEN SO.xtype = 'V' THEN 'View' ' + 'END AS TYPE ' + 'FROM dbo.syscomments as SC JOIN dbo.sysobjects as SO ON SC.id = SO.id ' + 'WHERE PATINDEX('%' + CAST(@SearchString AS VARCHAR(100)) + '%', SC.text ) > 0 ' + 'GROUP BY SO.name, SO.xtype ' + 'UNION ' + 'SELECT SUBSTRING(SO.name, 1, 40 ) as Object, 1 as Occurances, 'User Table' as TYPE FROM sysobjects as SO INNER JOIN syscolumns as SC on SC.id = SO.id WHERE SC.name LIKE '' + CAST(@SearchString AS VARCHAR(100)) + '' AND SO.xtype =' + ''U'' EXECUTE( @SQL ) RETURN Source: http://www.sqlservercentral.co...

Maayakobarima · Jan 8, 2009 8:52 AM

I have one Scenario: I have some events in my Notification Services in SQL 2000 and SQL 2005. I have to migrate them to SQL 2008. How can I migrate them? Although Microsoft has given some Patches for Notification Service to migrate to SQL Server 2008. Since Notification Service is already removed from 2008 so in near future, there would be no support from Microsoft. So Is there any third Party tool for Notification Services or how can I convert them to SSRS or to write policies on Declarative Management Framework.

Maayakobarima · Jan 8, 2009 9:02 AM

This conversation is preserved exactly as it was on the original Sajha.com and can't accept new replies.

Start a New Discussion

You might be interested in...

Recent Classifieds View all
Upcoming Events View all
Service Providers View all