.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

a function in the where clause?

Posted By:      Posted Date: September 09, 2010    Points: 0   Category :Sql Server
I have this where clause that I use in so many different places, I wanted to see if it is possible to have it as a function or something so that in the case I have to ever change it, I won't have to go through 50+ queries to change it.   Select * From Table1 Where IsTableAvailable = 1 AND (IsTableBroken = 0 OR IsTableFixed = 1)    

View Complete Post

More Related Resource Links

Function and Variable declaration with out an 'As' clause


I get a message - "Function without an 'As' clause" for HMAC_MD5 and "Variable declaration without an 'As' clause" for Key and Value.  But the code works.  But the messages still exists.  Is there a way to fix this to avoid the messages?

Function HMAC_MD5(ByVal Key, ByVal Value)


Use of PATINDEX function in select clause With Linq

hello       i have an problem to use of PATINDEX function in select clause with Linq.      if anyone have any clue about it then please update me its urgent.Thanks In Advance.

Order By clause in RowNumber function slowing down the performance of my query.



I have a query which has a paging functionality and for which i'm using ROW_NUMBER() function. The order by clause in my rownumber function is dynamic and gets changed all the time when ever the sp is called. It works fine for few columns but for one column which is of datetime datatype, it takes lot of time. Amazing thing is with when i sort by the same column in descending order, the query runs in a sec but ascending order takes lot of time :(.

I tried creating a non clustered index(as i already i have a clustered index on that table) on that datetime column but it did not help me.

Could you please suggest what i can do to improve the performance.






SQL MAX() function selecting ALL columns and not only those in the GROUP BY clause


A school has classes. Each class has students. Each student may take up one or several courses.

One only table with thousands of rows contains the following columns (and some others):

  1. Student´s class
  2. Student id-number
  3. Student's course
  4. Student's grade (in the course)
  5. Some other rows. This table has about 25 rows

I need an only SELECT that brings ALL ROWS for each student's highest grade (grades are numbers, not letters).

In the example bellow, I have listed a fragment of the table and I have emphasized with bold and italic characters the rows that are supposed to be selected:

          Class       ID-number     Course     Grade     Row5   Row6   Row7... 

  1. Class-A         100001     Math&n

max() agreate function and having clause not working as expected


I wil try to describe below my issue, starting with the query i use.

SELECT     b.[id_training_MD],
FROM [training_MasterData] as a
inner join [training_Log] as b
    on a.id_training_MD = b.id_training_MD
inner join [training_Q_Log] as c
    on b.id_training_Q_Log = c.id_training_Q_Log
WHERE (a.[Category] = 'Networking')  and  (c.[employeeID] = '123')

group by b.[id_training_Q_Log],b.[id_training_MD],b.[trainingScore]   
having b.[id_training_Q_Log] = (select distinct max(b.[id_training_Q_Log]) FROM [training_Log])

My tables are:

CREATE TABLE [dbo].[Training_MasterData](
    [id_Training_MD] [int] IDENTITY(1,1) NOT NULL,
    [Category] [varchar](50) NOT NULL,
    [TrainingName] [varchar](100) NOT NULL

Example of data from table:
[id_Training_MD]    [Category]         [TrainingName]

can i create a Clr ud Aggregate Function with over/ order by clause?


i want create a UD Aggregate like  Row_Number () for using with 'Over (Order By ...) ' (not like sum() over (part....)

is it possible?

Power of using Clause in SharePoint

The Using Clause will help to avoid memory leaks in SharePoint by automatically Disposing the MOSS objects.

For example when we create SPSite and SPWeb objects, if we don't dispose it explicitly it might create memory leaks,

Content page control passes as argument to javascript function


Here is the content page:


<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="JavaDynamicCopyValue.aspx.cs" Inherits="JavaDynamicCopyValue" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
 <script type="text/javascript" >
 function copyValue(input, output )
   ouput.value = input.value;
   return true;
 <asp:TextBox ID="txt1" runat="server" onchange="copyValue(this,document.getElementById('<%=txt2.ClientID%>'))"></asp:TextBox>
    <br />
    <br />
    <asp:TextBox ID="txt2" runat="server"></asp:TextBox>


I got a javascript run time error says output is undefined. if I view source of the page, the txt1 markup became:

<input name="ctl00$ContentPlaceHol

connection to SQL Server files (*.mdf) require SQL server express 2005 to function properly.


I dont have the SQL EXPRESS installed instead I have SQL Standard Edition.

 I have two SQL Server instances installed.

 1- UserLT (this is sql 2000)
2- UserLT\SQL2005 (this is SQL 2005 named instance)

But when i try to add a database to my VS website project I get the following error:

Connection to SQL Server files (*.mdf) require SQL server express 2005 to function properly. please verify the installation of the component or download from the URL: go.microsoft.com/fwlink/?linkId=4925

I went in Tools>Opetions>DataBase tools>Data Connection>Sql Server Instance Name (blank for default)

and changed the "SQLEXPRESS" to "USERLT\SQL2005".

But I still get the same error message. Any ideas how i can resolve this issue?

Public Shared function doubt????

I am using VB.net/ASP.NET and SQL Server 2000 for a web application.

For populating the dropdowns, I wrote a Public Shared function LoadDDL(), in which I pass the dataset and dropdown name to set.

I have my doubts that this function will produce unexpected results for concurrent users. And will mix the results among sessions because it is a Shared function.

I am confused here. Is it the right way to go?

Please advice. Thanks in advance.


Trim function in C Sharp

How do i use "trim" function in C Sharp? I have a string and i want to strip off spaces from the end of the string. Any idea how do i do it??


Pure C++: Invoking Generic or Function Templates


As I promised last time, in this month's column I'll walk through the process of defining and invoking a generic or template function under C++\CLI. A function template or a generic function begins with the template or generic keyword followed by its parameter list.

Stanley B. Lippman

MSDN Magazine October 2005

Cutting Edge: Using an Eval Function in Web Services


Web Services are often presented as the perfect tool for pro-grammers. They're interoperable, based on open standards such as SOAP and WSDL, and are fully integrated with the Microsoft® . NET platform.

Dino Esposito

MSDN Magazine September 2002

way of calling "javascript function of parent window from child window."

The article way of calling "javascript function of parent window from child window." was added by raja.s on Sunday, June 06, 2010.

Hi,Here i am going to explain how to call the javascript function of a parent window from the child window(pop-Up).Some may know before reading this post.Parent Java Script Function:script language="Javascript" type="text/javascript">

Need function to find difference between two dates


Hi all

I need a function written in vb to find the exact month difference between two dates.

For example

    Start Date : 01/01/2010

    End Date   : 15/02/2010

 then the difference value should be like this 1.5  i.e i need the difference in decimal value.

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend