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

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

Dynamic query for Null field checking

Posted By:      Posted Date: August 28, 2010    Points: 0   Category :Sql Server
Hi I want dynamically check the data Formation query in SQL server please  provide me the query

View Complete Post

More Related Resource Links

Dynamic query for Null field checking

Hi I want dynamiclly find the table to null values finding.. Please give me quickly   Regards Ram

Dynamic query for datalength field checking

Hi   Please tell me the dynamic query length in table

dynamic query with a null parameter to dont take in cosideration if null


Hi guys,

Do you know in a dynamic query how can I manage if a parameter isnull or not.

declare @businessunitidname varchar(15)
set @businessunitidname = NULL;
--print @businessunitidname

declare @eu_reporthubname varchar(15);
set @eu_reporthubname = Null;
declare @ownerid varchar(15);
set @ownerid = Null;

declare @SQL varchar(4000);

SET @SQL = ';with cte as
	select ''eu_mondayamid'' as WeekName,0 as WeekVal union all
	select ''eu_mondaypmid'',0 union all
	select ''eu_tuesdayamid'',1 union all

How to check for null/empty strings on dynamic objects?


What is the proper way to check for null or empty strings on dynamic objects? This is the only solution I've found so far:

if (admin.PasswordHash.GetType() == typeof(DBNull) || admin.PasswordHash == string.Empty)

If the field is null, the object returned is DBNull.Value, but if the field is empty string, it's return as a System.String object. This makes it impossible to do regular "admin.PasswordHash == DBNull.Value" check, as that will fail whenever the field has been set to empty string. Is my example the right (and only) way to go?

dynamic 'Today field' in sharepoint


how to do i get a dynamic 'Today field' in sharepoint?

I found many examples such as this which is completely wrong.  In the example below the [Today] is only calculated on item creation and edit, not every time list item is accessed.
http://blogs.msdn.com/b/sharepointdesigner/archive/2008/08/01/date-functions-in-calculated-fields.aspx .

This is very important my customer wants it done asap.


Thank you.



nothing for members to see

How to use server side validation to ensure image field is not null


I'm having trouble accomplishing the above. Below is all the mark up and code. I'm not getting error messages, but the validate image function is not working (fileupload portion is working ok).

In my attempt below---not sure if it's the simplest or best validation approach anyway---the "UserId" parameter appears during rendering to be empty---but in most methods I have it successfully containing or referring to the logged-in user's identification.

Following is the control that refers to the image field (page = advertisement.aspx):

<asp:Image ID="Image" runat="server" ImageUrl ='<%#Eval("UserId","Image.aspx?UserId={0}") %>'


Following is the successful code behind for the page image.aspx referred to above (page = image.aspx.vb):

Partial Public Class Image

    Inherits System.Web.UI.Page

    Public Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        If Request.QueryString("UserId") IsNot Nothing Then

            ' Get the connection string from Web.config.

            Using conn As New Sq

Custom Dataflow componet in Null checking

Hi I want to create the custom Null checking and data length checking component. like Dataprofiling Please suggest it. Regards Ram  


We have the following query:   SELECT H.VEHICLE_ID,                 COUNT(ISNULL(H.HISTORY_ID, 0))            FROM VEHICLES V LEFT OUTER JOIN VEHICLE_HISTORY H              ON V.VEHICLE_ID = H.VEHICLE_ID           WHERE H.SPEED >= 65             AND CONVERT(DATE, H.GPS_TIME) = CONVERT(DATE, DATEADD(DAY, -1, GETDATE()))        GROUP BY H.VEHICLE_ID;   Unfortunately, if there inst a record for a vehicle for the current day in VEHICLE_HISTORY, or there inst a record over 65 in VEHICLE_HISTORY, the query simply does not include the result. How can we include all results (i.e. return 0)? What we want is the number of rows returned to match the number of rows in the vehicles table. I thought doing the LEFT OUTER JOIN would take care of this, and return a result for all vehicles.   Thanks.

Dynamic Class with Linq query Result

Hi, var   query = db.Customers.Where( "City == @0 and Orders.Count >= @1", "London", 10). OrderBy( "CompanyName"). Select( "New(CompanyName as Name, Phone)");    I am using this query as a sample which returns a dynamicclass type, and i need this should to converted to a list collections or datatable etc., As i am holding it in my wcf service with linqtosql as dataaccesslayer. Trying to send the results to the UI which i have consumes this service. Kindly help me in this. Thanks query = db.Customers

Updating a List item field value in a SPD Workflow is setting Date fields to null

Hello everybody,I faced a very weird behavior while creating a workflow in SPD against a Document Library.Here is the case:1- Create a document library in sharepoint site.2- Add a custom column of type DATE.3- Upload any document to the library4- Edit the item metadata and set the custom date field to any date you want.5- Now using sharepoint designer, create a very simple Workflow with only one action that updates the current item "Title" field to any value. (Note: In my case I set the workflow to start manually and not automatically)6- Save the workflow and then start it on the uploaded item.7- Now check the value of the date column after the workflow is finished.8- You will see that the Date field is Empty... (very weird)Notes:   1-This behavior will not appear on a standard list. it is only appearing in a Document library.  2- I am using WSS 3.0 SP2 + MOSS 2007 SP2. Also SharePoint designer 2007 SP2Did anyone face this situation and does it have a fix, or am I doing something wrong here... Please help.Regards,Maheed

Set up a validator that compare the value of the current field with an other (using Dynamic Data)

Hi! Most of it is in the title : I'd like have a validator on the DateTime_Edit template for example that allows to compare this field with an other DateTime field. My problem is when I am in the DateTime_Edit template of my "master field" (the one I want to check), how can I access to the other field given the architecture of Dynamic Data FieldTemplates? But perhaps I'm not thinking in a good way on this control. Any advice will be welcome. Thanks Raphaelp


Hi Everone,    Can any one help me out in creating a dynamic select statement, so far my SP look like belowALTER PROCEDURE [dbo].[CheckAccess]@TABLENAME VARCHAR(100),@JNID INT=0ASBEGIN    SET NOCOUNT ON;    DECLARE @SQ VARCHAR(500)    DECLARE @ID INT =0     SET @SQ= ' SET @ID = SELECT TOP 1 ID FROM ' +  @TABLENAME + ' WHERE PID ='+ @JNID       PRINT @SQ    EXEC(@SQ)       IF (@ID>0)      BEGIN        RETURN 1      END    ELSE      BEGIN        RETURN 0      ENDENDGOlet me know where i am going wrong

how to read a custom dynamic data meta data attribute in a field template

All --Please help.I need to know how to read a custom dynamic data meta data attribute in a field template.I know how to do it in a page template because I have a handle to the meta table on the page.However, I do not know how to get a handle to the meta column at run time in a field template.Can you help?Please advise.Thank you.-- Mark Kamoski

using a database field as a hyperlink query?

I have three tables in my sql database contactssurvey answersrespondent_initialContacts holds all customer data with custid. survey answers has assigned everyone how took the survey a number in a field called respondent_no.respondent_initial holds input from a webform where I populated it with the custid from contacts and respondent_no from survey answers before the webform input is inserted. I want to send an email to them that had there respondent_no in a hyperlink to the webform so that when they entered their data into the webform it would use the repondent_no to determine where to insert the form data.Example joe clicks http://www.myplace.com/order.aspx?23             Mike clicks http://www.myplace.com/order.aspx?125it would look up respondent_no (23) from the respondent_initial table and insert the data in that row in the database for joe's webform entry and it would look up respondent_no (125) from the respondent_initial table and insert the data in that row in the database for mike's webform entry.my code behind looks like this// Create command                comm = new SqlCommand("INSERT INTO respondent_inital (Practice_Name, Address1, Address2, City, State, Zipcode, Phone, Email, Contact, Dealer, item_9223, item_9129, item

Field method missing with LINQ query

H, I want to access the data from datatable object. When i trying to get the fieldslist usng "Field" method. But I could not find the method with my table object.  Eventhoguh i forcibly write a method and trying to access the fields, It is giving the below error for the first join in query. Rest of the lines are fine. What is the reason behind it. The errro: "Error 2 'LINQ2DB.SP_VS_OP' does not contain a definition for 'Field' and the best extension method overload 'System.Data.DataRowExtensions.Field<T>(System.Data.DataRow, string)' has some invalid arguments" What is the meaningof the error. Shall i do any other changes in the query line?                         var QueryChnl = from oSPOP in SPOP.AsEnumerable()                        join oDiscChannel in DiscChannel.AsEnumerable() on oSPOP.Field<int>("spid") equals oDiscChannel.Field<int>("SPID")                        join oChannel in Channel.AsEnumerable() on oDiscChannel.Field<in

Dynamic Query alternative?

Hi, I was trying to create a query to get some results for next five years and need to show next five years as Column names. So whatever the year user runs this query, it gives the results for the next five years. Then I realized this was not easy as I expected but managed to implement it using Dynamic Queries.I wrote the following code Ito implement that. But I'm not sure is this the best way to do this.   SET ANSI_NULLS ON  GO  SET QUOTED_IDENTIFIER ON  GO  CREATE PROCEDURE sp_RS_ScenariosforNext5Years  @ticker nvarchar(10),  @variable nvarchar(100)  AS  Declare @SQL varchar(1000)  SELECT @SQL = 'SELECT CASE Scenario '  SELECT @SQL = @SQL + ' WHEN ''A'' THEN ''case1'' '  SELECT @SQL = @SQL + 'WHEN ''B'' THEN ''case2'' '  SELECT @SQL = @SQL + 'WHEN ''C'' THEN ''case3'' '  SELECT @SQL = @SQL + 'WHEN ''D'' THEN ''case4'' '  SELECT @SQL = @SQL + 'WHEN ''E'' THEN ''case5'' '  SELECT @SQL = @SQL + 'WHEN ''F'' THEN ''case6'' '  SELECT @SQL = @SQL + 'WHEN ''G''
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