.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

convert Access query into SQL query

Posted By:      Posted Date: April 10, 2011    Points: 0   Category :



I had a application that use Access database. Now I planned it to convert into SQL. I am unable to convert a query into SQL.

SELECT company.id, company.isCaseActive, company.isActive, company.ClientName, company.OutletName, company.OutArea, company.city, company.Tregion, company.status, company3D.cnt3D, companyDrawing.cntCD, PhotoCompany.cntPC, CompanySurvey.cntCS, companyPlanogram.cntCP, CompanyLayout.cntLay

FROM (((((company LEFT JOIN (SELECT id, count(*) AS cnt3D FROM company3D GROUP BY id)  AS company3D ON company.id = company3D.id) LEFT JOIN (SELECT id, count(*) AS cntCD FROM companyDrawing GROUP BY id)  AS companyDrawing ON company.id = companyDrawing.id) LEFT JOIN (SELECT id, count(*) AS cntCP FROM companyPlanogram GROUP BY id)  AS companyPlanogram ON company.id = companyPlanogram.id) LEFT JOIN (SELECT id, count(*) AS cntCS FROM CompanySurvey GROUP BY id)  AS CompanySurvey ON c

View Complete Post

More Related Resource Links

Access the SQL Command Query Value Property from the OLEDB Container within a Script Task

Hello, I'd like to Access the SQL Command Query Value Property from the OLEDB Container within a Script Task so I can audit the queries which are executing. What is the syntax for this or does anyone have a sample on how to do this? Thank you

How to access and query SDF file?

I get a sdf file.  I try to access it using SSMS 2005 and I get this error: You are trying to access an older version of a SQL Server Compact Edition database. If this is a SQL Server CE 1.0 or 2.0 database, run upgrade.exe. If this is a SQL Server Compact Edition 3.0 or later database, run Compact / Repair. [ Db version = 3505053,Requested version = 3004180,File name = D:\test.sdf ] (SQL Server Compact Edition ADO.NET Data Provider) How can I find out the edition of the SDF?


hai.......I am a biggner in SQL DB . but i started a complicated and painfull work in SQL SERVER 2008.the problem  convert Oracle hierarchical query to SQL query please help. the query SELECT DISTINCT         LEVEL LVL,         SCH.NSCHEDULE_SL,         SCH.NSCHEDULE_SL_FM,         SCH.CSHED_CNAMEFROM  FA_SCHEDULES SCH WHERE     LEVEL  = 1 AND    NSCHEDULE_SL_FM  IS NULL AND    NBRANCH_SL  = 2  CONNECT BY PRIOR SCH.NSCHEDULE_SL_FM  = SCH.NSCHEDULE_SL AND    NBRANCH_SL  = 2please help me

Convert the Sql query to LINQ .. can anyone please help me I need it ASAP as no time to learn and im

 SELECT DISTINCT HP.PartNumber, HP.MIRevision, HPEXData.InstructionImage, EXAttr.PlacementImage from dbo.HardwareParts HP   INNER JOIN dbo.HardwarePartEXData HPEXData     ON HP.HardwarePartID = HPEXData.HardwarePartID   LEFT JOIN dbo.EXMIAttributes EXAttr    ON EXAttr.EXTypeID = HPEXData.EXTypeID   WHERE    HP.PartNumber = @PartNumber     AND REPLACE(SUBSTRING(HP.MIRevision, 1, 13),'.','') >= REPLACE(SUBSTRING(ISNULL(@PartRevision,''), 1, 13),'.','')    AND ISNULL(HP.ProjectID,'') = ISNULL(@SINumber,'')    AND (@ChassisIdentifier IS NULL OR HPEXData.EXMI_Type NOT IN ('Add In Card','Storage') OR EXAttr.ChassisIdentifier = @ChassisIdentifier)   END;anji

Need to convert query string(date - 09/15/2010) to a text format - yyyymmdd

I am fairly new to C # and need some assistance with a form page.  I have created a simple form that requires the user to select a beginning date and ending date.  I then pass the values to my code behind page via query strings.  I have them passing, but I need the format to be change to a different format.  Unfortunately the database does not use the standard date format.  It requires the date to be in a text format as YYYYMMDD.Form: <tr> <td> Beginning Date:</td> <td><asp:TextBox runat="server" ID="begDate"></asp:TextBox> <asp:Image ID="Image2" ImageUrl="~/images/calendar_schedulehs.png" runat="server" /></td> </tr> Code Behind: protected void createReport_Click(object sender, EventArgs e) { StringBuilder url = new StringBuilder("Report/TopCustomer.aspx?"); url.Append("BegDate=" + begDate.Text); url.Append("&EndDate=" + endDate.Text); url.Append("&Brnch=" + ddlLocation.SelectedValue); Response.Redirect(url.ToString()); Current URL: TopCustomer.aspx?BegDate=09/15/2010&EndDate=09/30/2010&Brnch=300I need to have the above URL change to:TopCustomer.aspx?BegDate=20100915&E

CAML query to access List data across multiple site collection.

Hi   Is there any way to get the Task List data across multiple site collection using CAML query. Currently, I have the code which will retrieve the data from a single site collection. Below is the code.                           /***************************************************I am using Moss2007.Thanks!Ravi             SPSiteDataQuery q = new SPSiteDataQuery();             q.ViewFields = "<FieldRef Name=\"Title\" />" "<FieldRef Name=\"Status\" Nullable=\"TRUE\"/>";             q.Lists = "<Lists ServerTemplate=\"107\"/>";             q.Webs = "<Webs Scope=\"SiteCollection\"/>";             q.Query = "<Where>" +                                "<Eq>" +                                     "<FieldRef Name=\"Status\" />" + "<Value Type=\"Choice\">Not  Started</Value>" +                                     "</Eq>" +                         "</Where>";             DataTable dt=null;             using (SPSite s = new SPSite("http://banglabguest1:31000/"))             {                 SPWeb w = s.OpenWeb();                 dt = w.GetSiteData(q);                 w = null;             }                              *************************

help with access query

hi i have table `MyTbl` that contain `date1, date2, date3`     if date1=null i need that in field memo will be 'A'     elae if date2=null i need that in field memo will be 'B'     else if date3=null i need that in field memo will be 'C' is it can made on access 2007 in query ? thank's in advance

is there any tool or add-on for write color and comfortable query on access-2007 ?

hi is there any tool or add-on for write color and comfortable query on access-2007 ? thank's in advance

Converting an Access pivot query to SQL 2005


Hi, I am new to table pivot and would like to know how to go about converting the following query in Access to SQL Server 2005:


SELECT tbl_Proj_Budget.PROJ_ID,
FROM tbl_Proj_Budget 
GROUP BY tbl_Proj_Budget.PROJ_ID 

1) what does the 1st line mean?


2) How would I conver this to TSQL ?




Convert sql query in linq


hello guys,

how convert this sql query in linq,

SELECT COUNT(AdvisorID) AS AdvisorRegisterLast2Days FROM ob_Advisor WHERE CONVERT(varchar,CreationDate,101) BETWEEN CONVERT(varchar,DATEADD(day,-4,DATEADD(day,2,GETDATE())),101) AND CONVERT(varchar,GETDATE(),101)

Plese help me out


"Access Denied" Error for WMI Reader Task Query


I am using SSIS to query all servers for their disk space from a remote machine using the WMI Reader Task by providing the Administrator user credentials to access all servers. The package execution fails and I get the following error in the Execution Results pane:

[WMI Data Reader Task] Error: An error occurred with the following error message: "Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))".

However, I do get the results for the Development and Staging servers but the Production servers come back with an Access Denied message. The user credentials for the Dev and Staging servers belong to the "Administrator" group whereas for the Production, the user belongs to the "Administrator" and the "User" group as well.

I am pretty much sure that it has something to do with access to running WMI queries on the servers but I could not find a forum that discussed this issue elsewhere. I even checked for the DCOM Security settings after a few searches led me to a post about "Connecting to WMI on a Remote Computer" on an msdn forum but they seem to be enabled for all environments.

My production database sits on a cluster, so does that make any difference? I have not used the WMI ta

Access Services - The query has too many output columns.


Trying to port a database from Access (2000 or older! via an intermediate upgrade to 2010) to use Access Services on Sharepoint 2010.  The main data entry table contains 41 columns of data and I'm getting this error when trying to load it as a web form: "The query has too many output columns. The maximum number of output columns is 40."

I take it the database needs re-designing to split some of the data off into separate tables to be accessed on-demand?  Or is there a setting inside Sharepoint I can tweak to get the form to display?

Inconvenient SharePoint 2010 Content Query Web Part and Anonymous Access


Morning every one

I am hoping some one has found a work around regarding this.

I am using a JQuery random 'quote' generator (http://nextconnect.blogspot.com/2009/12/jquery-random-quote-viewer.html) in my site.I have enabled full anonymous access. My issue is that it still prompts you for the login in order to see the quote generator. I have tried the "ViewFormPagesLockDown" fix but it isn't even activated on my site. And now I am at a complete loss. I did some googling (Read 5 hours) and it seems that in Sharepoint 2010 doesn't have a work around for this and I am really hoping I am wrong.


Any ideas?


Have a great friday :)


SQL query to access data using C#



I am having 2 tables A and B

Am downloading data into A row by row which contains columns Id ,date,value .B has Id,date,Location.B is present in the database.

I want to write a sql query which compares the ids of A and B and stores the info only when ids are equal.

B is acting like a filter.Can anyone tell me the code to do this using C#

Thank you in advance.

convert query to derived table


I have the query like that:

SELECT orderid, orderdate, custid, empid,
		  ROW_NUMBER() OVER (PARTITION BY orderdate ORDER BY orderid) rownum
FROM [TestSQL].[Sales].[Orders]

How can I do it with derived table?



How to query a datetime field in access database using ASP.NET



I am using an Access database with one of the Table columns defined as Date/Time field.


I am trying to use ASP.NET 4.0 Web forms application to query and retrieve the row based on the DateTime field.

Here is my code snippet:

      string connectionString = WebConfigurationManager.ConnectionStrings["AccessDB"].ConnectionString;

      OleDbConnection oleDBConn = new OleDbConnection(connectionString);

      DateTime dt = new DateTime(dtBatchCreation.Year, dtBatchCreation.Month, dtBatchCreation.Day, dtBatchCreation.Hour, dtBatchCreation.Minute, dtBatchCreation.Second);

      //string sql = "SELECT [BatchID] FROM [Batch] WHERE [BatchCreationDate] = " + String.Format("{0:#yyyy-MM-dd hh:mm:ss tt#}", dt);
      string sql = "SELECT [BatchID] FROM [Batch] WHERE [BatchCreationDate] = @BatchDate";

      string s = @String.Format("{0:yyyy-MM-dd HH:mm:ss}", dt);

      OleDbCommand cmd = new OleDbCommand(sql, oleDBConn);

      //cmd.Parameters.AddWithValue("@BatchDate", s);


how to convert date type in SQL query output ?


In my database when anyone registers - By default the registration time is saved as UTC universal time zone.

But i want to display everything on the website in (GMT-05:00) Eastern Time (US & Canada)

I am using this SQL QUERY to display registration date:

SELECT TOP (5) Username, CustomerID,  RegistrationDate = CONVERT(VARCHAR(12),RegistrationDate,107)  FROM Customer ORDER BY RegistrationDate DESC

And, i am displaying it like this:

<asp:Label ID="nameLabeldate" runat="server" Text='<%# Eval("RegistrationDate") %>' />

The problem is the output is getting displayed as : 10/20/2010 1:36:01 PM

I know RegistrationDate is datetime stamp that's why i am getting output in this format.

But i want to display RegistrationDate as: Oct 20, 2010 at 1:36pm -> according to (GMT-05:00) Eastern Time (US & Canada) ORDER BY RegistrationDate in Desc (top most will be last registered user)

I need help with sql query by which i should be able to accoplish my desired output..please help...

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