How To Run Insert Query For Required No.of Times With Different Parameters...?

Apr 22, 2008

Hi All,

I have two tables in my database.
I want to insert date and no.of hours worked on that day for a particular project.
So in a week if end user enters 7 dates and hrs for each day......
i have to insert those values into the table against one project only.
Can any one please help me out how to run insert query for 7 times (in a week) with different parameters

Thanks,
Praveen

View 5 Replies


ADVERTISEMENT

One Or More Parameters Required To Run The Report

May 12, 2008

I am doing report development against cube. I have a main report and a sub report in the main report. I am collecting the parameters in the main report and passing into sub report which has the same exact parameters. (I am assigning parameters to the sub report from the Fields collection. If I assign from the Parameter collection, it works fine, but I need to do based on Fields collection because I have my grouping like that)

I am getting the error above, what could I be doing wrong?

View 1 Replies View Related

Problem With Database: No Value Given For One Or More Required Parameters.

Nov 21, 2006

I am working on my first project, and using Visual Web Developer 2005, and I am having one heck of a time with one of my pages. I am making a makeshift shoppingcart program for one of my classes, and I can't get the checkout page to work.  All my other pages work just fine, and this is the only one that won't work. I am hoping someone is able to help meI am attaching what I think is causing the problem, hopefully someone might see something amiss: These are my AccessDataSources<asp:AccessDataSource ID="adsAddNewOrder" runat="server" DataFile="~/App_Data/GoalieStore.mdb" InsertCommand="INSERT INTO Orders(OrderID,CustomerID,SalesTaxRate,Shipping) VALUES (?,?,0.14,25)" SelectCommand="SELECT OrderID, CustomerID FROM Orders"></asp:AccessDataSource><asp:AccessDataSource ID="adsAddNewOrderDetails" runat="server" DataFile="~/App_Data/GoalieStore.mdb"InsertCommand="INSERT INTO OrderDetails(ProductID,OrderID,Quantity) SELECT ProductID,OrderID,Quantity FROM Cart WHERE (CustomerID = ?)" SelectCommand="SELECT ProductID, OrderID FROM OrderDetails"></asp:AccessDataSource><asp:AccessDataSource ID="adsClearCart" runat="server" DataFile="~/App_Data/GoalieStore.mdb"  DeleteCommand="DELETE * FROM Cart WHERE (CustomerID = ?)" SelectCommand="SELECT Cart.* FROM Cart"></asp:AccessDataSource>and I have VB.Net code as follows:    Protected Sub ClearCart()        'Create a Delete Query Parameter using a Session variable tag        Dim paramCID As New SessionParameter        paramCID.SessionField = "CustomerID"         adsClearCart.DeleteParameters.Clear()   'clear all existing Delete Query parameters        adsClearCart.DeleteParameters.Add(paramCID) 'add the Session variable Parameter        adsClearCart.Delete()   'run the query    End Sub    Protected Sub btnNewOrder_Click(ByVal sender As Object, ByVal e As System.EventArgs)        Dim paramCID As New SessionParameter        paramCID.SessionField = "CustomerID"        Dim paramOID As New SessionParameter        paramOID.SessionField = "OrderID"        'add the parameters to the Order table Insert Query and run the Query        adsAddNewOrder.InsertParameters.Clear()        adsAddNewOrder.InsertParameters.Add(paramOID)        adsAddNewOrder.InsertParameters.Add(paramCID)        adsAddNewOrder.Insert()        'add the parameter to the OrderDetails table Insert Query and run the Query        adsAddNewOrderDetails.InsertParameters.Clear()        adsAddNewOrderDetails.InsertParameters.Add(paramCID)        adsAddNewOrderDetails.Insert()        'Clear Cart        ClearCart()        Server.Transfer("confirm.aspx")    End Sub The user presses a button to confirm there order, and thats when I get the error "No Value given for one or more required parameters." Hope someone can help!Thanks,Greg 

View 1 Replies View Related

Updating A Field - No Value Given For One Or More Required Parameters

May 7, 2015

I have a column being added with VB.net, but I can't figure out the syntax. I get the error No Value given for one or more required parameters. But no clue which one. Below is the code I am attempting.

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim conp As String = "SELECT * INTO [Input] FROM [Text;DATABASE="
Dim aCon As String = "W:Glenn-123456VDDDataTest.mdb"
Dim scon As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source="
Dim Conn_1 As New OleDbConnection(scon & aCon)

[Code] .....

View 3 Replies View Related

Transact SQL :: Error - No Value Given For One Or More Required Parameters

May 16, 2015

Below code gives the error "No value given for one or more required parameters"

strSQL = "insert into FILE_UPLOAD(RefNo, FileName, FileType, FileData, FileDescription, Created, CreatedBy) values "
strSQL = strSQL & "(?, ?, ?, ?, ?, ?, ?)"
Dim cmd As New OleDbCommand
cmd.Connection = objCommon.oConn
cmd.CommandText = strSQL
cmd.Parameters.Add("@RefNo", OleDbType.VarChar).Value = ""
cmd.Parameters.Add("@FileName", OleDbType.VarChar).Value = strFileName

[code]....

View 3 Replies View Related

System.Data.OleDb.OleDbException: No Value Given For One Or More Required Parameters.

Jan 23, 2007

Can someone help me with this error, so the page can show the rocords, its works on my PC but not at my host. 
I get this error:
Exception Details: System.Data.OleDb.OleDbException: No value given for one or more required parameters.Source Error:



An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. Stack Trace:



[OleDbException (0x80040e10): No value given for one or more required parameters.]
System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult) +267
System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult) +192
System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult) +48
System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method) +106
System.Data.OleDb.OleDbCommand.ExecuteReader(CommandBehavior behavior) +111
System.Data.OleDb.OleDbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior) +4
System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +141
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +137
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable) +83
System.Web.UI.WebControls.SqlDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments) +1770
System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +17
System.Web.UI.WebControls.DataBoundControl.PerformSelect() +149
System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +70
System.Web.UI.WebControls.GridView.DataBind() +4
System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() +82
System.Web.UI.WebControls.CompositeDataBoundControl.CreateChildControls() +69
System.Web.UI.Control.EnsureChildControls() +87
System.Web.UI.Control.PreRenderRecursiveInternal() +41
System.Web.UI.Control.PreRenderRecursiveInternal() +161
System.Web.UI.Control.PreRenderRecursiveInternal() +161
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1360

 
My code is:
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="CMS_Default.aspx.vb" Inherits="cmssystem_CMS_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="CM_form" runat="server">
<div>
&nbsp;
<asp:GridView ID="GridView1" runat="server" DataSourceID="CMSqlDataSource">
</asp:GridView>
<asp:SqlDataSource ID="CMSqlDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:CMConnectionString %>"
ProviderName="<%$ ConnectionStrings:CMConnectionString.ProviderName %>" SelectCommand="SELECT [SiteMainID], [SiteMainIdentity], [SiteMainText] FROM [MainSiteText] ORDER BY [SiteMainID]">
</asp:SqlDataSource>
</div>
</form>
</body>
</html>

View 7 Replies View Related

Integration Services :: SSIS 2012 And Required Package Parameters

Nov 4, 2015

I'm after running into something in SSIS 2012 that I fail to grasp.

I have a package that provides a service to other packages. In order to provide that service it needs 4 parameters provided by the caller. So naturally I'm thinking I make those 4 parameters 'required'.

The caller uses Execute package task and provides the 4 parameters on the parameter mapping tab.

Yet the packages fails with the error message that one or more required parameters weren't provided.

View 7 Replies View Related

Don't Want To Insert Same Values 2 Times.

Sep 6, 2006

create proc dbo.usp_CatchAddressException @tableName varchar(500) as
-- alter proc dbo.usp_CatchAddressException @tableName varchar(500) as


begin
set nocount on
declare @sql varchar(700)

-- truncate table tempException
set @sql = 'insert hava_dcde.dbo.STREET_EXCEPTION (id_town, id_voter, pre_value, nbr_exception, date_stamp)
select a.id_town, a.id_voter, substring(a.ad_str1, 1, len(a.ad_str1) - charindex('' '', reverse(a.ad_str1))), ''20'', getdate()
from HAVA_DCDE.dbo.' + quoteName(@tableName)+ ' a
where substring(a.ad_str1, 1, len(a.ad_str1) - charindex('' '', reverse(a.ad_str1))+1) not in
(select nm_street from HAVA_DCDE.dbo.state_streets ss)'
-- and a.id_town = + @tableName
-- print(@sql)

exec(@sql)
set nocount off
end
---------------------------------------------------


when i run this SP 2 times, it will insert the values 2 times.
what should i do if i don't want to insert the same values 2 times?
I'm confussed, Should i use update? any input will be appreciated.

View 20 Replies View Related

My INSERT Statements Works... 8/10 Times

Jun 8, 2004

I'm using the following code to add some data to a table:
Dim rand As Random = New Random
Dim num As Int32 = rand.Next(10000000)
Dim strConn as string = "......."
Dim sql as string = "INSERT INTO tblitemid (itemid, userid, datetime, supplier, comment, commenttype, uniqueid) VALUES ('" & label1.Text & "', '" & user.identity.name & "', '"& System.DateTime.Now & "','3763' ,'" & textbox1.text & "' , 'C' ,'" & num & "')"
Dim conn as New SQLConnection(strConn)
Dim Cmd as New SQLCommand(sql, conn)
Try
conn.Open()
Catch SQLExp as SQLException
Response.Write ("An SQL Server Error Occurred: " & e.toString())
Finally
cmd.ExecuteNonQuery
conn.Close()
End Try


As far as I can tell the code works fine. But for some odd reason I click the button, the code execute and the page closes as it should, but the data is never inserted into the database. I cant really seem to pick up on any paterns for why this would be happening. As a rough guess I'd say it doesnt insert the data 1 out of every 5 times or so it seems. Anyone every have any experience with this? Any comments would be helpful, cuz I'm at a loss.
If youd like to see more code let me know....
Thanks,
Scott

View 3 Replies View Related

Insert Fails----- Database Times Out

Mar 26, 2001

Hi all,

I have a table with 4869068 rows and when some one tries to insert the records into this table the database times out....Does any one know what could be the reason and from where do I start debugging.
I have no problem with the disk space?

Thanks,
Venu

View 1 Replies View Related

INSERT Same Record 1000 Times

Jan 14, 2008



Ok, so I have a primary table that contains the count of a linked table. Since I can let the identity update itself, I should be able to insert the same values into the linked child table.

I need to put the same record in the child table 1000 (that's an arbitrary number, this will be programatically determined by the user) times.

I understand that I can do this:


INSERT INTO SomeTable (Cols) VALUES (vals)
GO 1000

However, I can't make this work when doing an ADO.NET ExecuteCmd. It doesn't like the Go 1000 part of it.

Does anyone have an idea how I can do this VERY QUICKLY without having to execute a separate insert for every item (or batch them)?

The number could be as high as 250,000 in the child table.

Thanks!

View 16 Replies View Related

High Insert Actiivty At Unexpected Times?

Apr 5, 2000

Hello:

I am supporting a financial application on mssql 6.5,sp4.

Other than at month-end when activiy is high, we have at some unexpected heavy insert activlty as well as deletes at unexpected times. Other than periodically watching 'current activity' or running sp_who2, we aren't sure when this happens and by whom if we don't see it.

Does any one know how I can monitor this unexpected activity?

IS there I can run periodically to trap which spid and/or user who is running such activity?

THanks.

DAvid Spaisman

View 1 Replies View Related

Power Pivot :: Dynamical Pass Parameters To Queries - Automatically Pull Required Region Data

Aug 18, 2015

I pull data from Sql Server through the  query, I want to pass the region parameter to the power pivot connection query. So that I can automatically pull the required region data.  The parameter should pick the value from the excel range. And also how to control this through VBA 

View 4 Replies View Related

SQL 2005 Insert Code Help Required

Dec 21, 2007

Hi I am trying to inset data to my sql 2005 database using a webform.. the code I have is
  3    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 4    5    ConnectionString="<%$ ConnectionStrings:SQL2005440975 %>" 6    7    InsertCommand="INSERT INTO [dbo.asp.net_Addresstbl] ([Salutation], [fname], [sname], [Daydb], [Monthdb], [Yeardb], [txtOrg], [txtLine1], [txtLine2], [txtLine3], [txtTown], [txtPostcode], [UserID]) 8    9    VALUES (@Salutation, @fname, @sname, @Daydb, @Monthdb, @Yeardb, @txtOrg, @txtLine1, @txtLine2, @txtLine3, @txtTown, @txtPostcode, @UserID)" 10   11   <InsertParameters>12                                           <asp:FormParameter FormField="Salutation" Name="Salutation" Type="String" />13                                           <asp:FormParameter FormField="fname" Name="fname" Type="String" />14                                           <asp:FormParameter FormField="sname" Name="sname" Type="String" />15                                           <asp:FormParameter FormField="Daydb" Name="Daydb" Type="Decimal" />16                                           <asp:FormParameter FormField="Monthdb" Name="Monthdb" Type="String" />17                                           <asp:FormParameter FormField="Yeardb" Name="Yeardb" Type="Decimal" />18                                           <asp:FormParameter FormField="txtOrg"Name="txtOrg" Type="String" />19                                           <asp:FormParameter FormField="txtLine1" Name="txtLine1" Type="String" />20                                           <asp:FormParameter FormField="txtLine2" Name="txtLine2" Type="String" />21                                           <asp:FormParameter FormField="txtLine3" Name="txtLine3" Type="String" />22                                           <asp:FormParameter FormField="txtTown" Name="txtTown" Type="String" />23                                           <asp:FormParameter FormField="txtPostcode"Name="txtPostcode" Type="String" />24                                           <asp:FormParameter FormField="UserID" Name="UserID" Type="Object" />25   </InsertParameters>26   </asp:SqlDataSource>27   28   <asp:DropDownList ID="Salutation" runat="server" ValidationGroup="Address">29                                   <asp:ListItem>Choose One</asp:ListItem>30                                   <asp:ListItem>Mr.</asp:ListItem>31                                   <asp:ListItem>Mrs.</asp:ListItem>32                                   <asp:ListItem>Ms.</asp:ListItem>33                                   <asp:ListItem>Miss.</asp:ListItem>34                                   <asp:ListItem>Rev.</asp:ListItem>35                                   <asp:ListItem>Doc.</asp:ListItem>36                                   <asp:ListItem>Other.</asp:ListItem>37                               </asp:DropDownList>38   39   <asp:TextBox ID="fname" runat="server" CausesValidation="True"></asp:TextBox>40   41   <asp:TextBox ID="sname" runat="server" CausesValidation="True"></asp:TextBox>42   43   <asp:DropDownList ID="Daydb" runat="server" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">44                                   <asp:ListItem>Day</asp:ListItem>45                                   <asp:ListItem>01</asp:ListItem>46                                   <asp:ListItem>02</asp:ListItem>47                                   <asp:ListItem>03</asp:ListItem>48                                   <asp:ListItem>04</asp:ListItem>49                                   <asp:ListItem>05</asp:ListItem>50                                   <asp:ListItem>06</asp:ListItem>51                                   <asp:ListItem>07</asp:ListItem>52                                   <asp:ListItem>08</asp:ListItem>53                                   <asp:ListItem>09</asp:ListItem>54                                   <asp:ListItem>10</asp:ListItem>55                                   <asp:ListItem>11</asp:ListItem>56                                   <asp:ListItem>12</asp:ListItem>57                                   <asp:ListItem>13</asp:ListItem>58                                   <asp:ListItem>14</asp:ListItem>59                                   <asp:ListItem>15</asp:ListItem>60                                   <asp:ListItem>16</asp:ListItem>61                                   <asp:ListItem>17</asp:ListItem>62                                   <asp:ListItem>18</asp:ListItem>63                                   <asp:ListItem>19</asp:ListItem>64                                   <asp:ListItem>20</asp:ListItem>65                                   <asp:ListItem>21</asp:ListItem>66                                   <asp:ListItem>22</asp:ListItem>67                                   <asp:ListItem>23</asp:ListItem>68                                   <asp:ListItem>24</asp:ListItem>69                                   <asp:ListItem>25</asp:ListItem>70                                   <asp:ListItem>26</asp:ListItem>71                                   <asp:ListItem>27</asp:ListItem>72                                   <asp:ListItem>28</asp:ListItem>73                                   <asp:ListItem>29</asp:ListItem>74                                   <asp:ListItem>30</asp:ListItem>75                                   <asp:ListItem>31</asp:ListItem>76                               </asp:DropDownList>77   78   <asp:DropDownList ID="Monthdb" runat="server" style="text-align: left">79                                   <asp:ListItem>Month</asp:ListItem>80                                   <asp:ListItem>January</asp:ListItem>81                                   <asp:ListItem>February</asp:ListItem>82                                   <asp:ListItem>March</asp:ListItem>83                                   <asp:ListItem>April</asp:ListItem>84                                   <asp:ListItem>May</asp:ListItem>85                                   <asp:ListItem>June</asp:ListItem>86                                   <asp:ListItem>July</asp:ListItem>87                                   <asp:ListItem>August</asp:ListItem>88                                   <asp:ListItem>September</asp:ListItem>89                                   <asp:ListItem>October</asp:ListItem>90                                   <asp:ListItem>November</asp:ListItem>91                                   <asp:ListItem Value="12">December</asp:ListItem>92                               </asp:DropDownList>93   94   <asp:DropDownList ID="Yeardb" runat="server" style="text-align: left" 95                                   OnSelectedIndexChanged="Year_SelectedIndexChanged" 96                                   DataSourceID="YearDataSource" DataTextField="Year" DataValueField="Year">97                                   <asp:ListItem Selected="True">Choose Year..</asp:ListItem>98   </asp:DropDownList>99         <asp:AccessDataSource ID="YearDataSource" runat="server" 100        DataFile="~/App_Data/year.mdb" SelectCommand="SELECT [Year] FROM [Year]">101        </asp:AccessDataSource>102                          103  <asp:TextBox ID="txtFind" runat="server" CausesValidation="True" ValidationGroup="address"></asp:TextBox>104  105  <asp:Button ID="btnFind" runat="server" Text="Find" 106       OnClick="btnFind_Click" ValidationGroup="address" 107           OnClientClick="lstProperties" />108                      109  110          <asp:ListBox ID="lstProperties" runat="server" AutoPostBack="True" 111                   OnSelectedIndexChanged="lstProperties_SelectedIndexChanged" Visible="False" 112                                  Width="200px"></asp:ListBox>113                          114                              <asp:TextBox ID="txtOrg" runat="server" OnTextChanged="txtOrg_TextChanged" 115                                  ReadOnly="True" ValidationGroup="address2" Visible="False"></asp:TextBox>116                          117                              <asp:TextBox ID="txtLine1" runat="server" ReadOnly="True" Visible="False"></asp:TextBox>118                          119                              <asp:TextBox ID="txtLine2" runat="server" ReadOnly="True" Visible="False"></asp:TextBox>120                          121                              <asp:TextBox ID="txtLine3" runat="server" ReadOnly="True" Visible="False"></asp:TextBox>122                          123                              <asp:TextBox ID="txtTown" runat="server" ReadOnly="True" Visible="False"></asp:TextBox>124                          125                              <asp:TextBox ID="txtPostcode" runat="server" ReadOnly="True" Visible="False"></asp:TextBox>126                          127                              <asp:Label ID="lblAddress" runat="server" CssClass="style9"></asp:Label>128                                          129                              <asp:Button ID="submitaddress" runat="server" Text="Add Details" 130                                  style="text-align: centre" CommandName="Submit" 131                                  ValidationGroup="address" PostBackUrl="~/MemberPages/account.aspx" />132  133  </asp:Content>
 Will this code work? if not can you explain why not and offer an example that will work. In the mean time I am reading up on these insert statements.
 
Regards
Mal

View 5 Replies View Related

SQL Query Load Times

Feb 10, 2006

I have an VB.NET web app which performs a fairly complicated SQL query. It seems in the morning, the 1st time the page is loaded (and query executed) it takes up to 10-15 seconds to complete loading. Sometimes it even times out. However anytime after that, the page loads up (even from another computer) in about 4-5 seconds. Can someone explain the reason for this and how I might fix the load times in the morning?

Thanks

View 1 Replies View Related

Query - Between To Dates And Between To Times

Jul 24, 2001

Hi there, I'm a little bit stumped on this one.

I have a column in a table that records when the date and time of an event took place.

Table Name: Chronicle
Column Name: Created (of type DateTime)

I would like to select the Chronicle records that are between two dates.
(e.g. 1 May 2001 and 20 May 2001)
And I would like to select those records that are between two times.
(e.g. 6:00am and 1:00pm)

Does anyone know how to do this or have any pointers for me?
I can see it would be easier if I had the date in one column and the time in the other.
Can it be done without doing that?

cheers,
Hamish

Hamish Norton
hamish@liftrider.com

View 1 Replies View Related

Excessive Query Execution Times

Mar 16, 1999

We recently upgraded from SQL 6.5 to SQL 7. I have a few .sql files that were each running around 5 - 8 minutes under 6.5. These same files now each take over 30 minutes to run. Has anybody had problems with their queries taking longer to run under 7.0? These files are quite large and are comprised of 3 - 4 batches with several queries in each batch. If anybody has any thoughts on the cause please let me know.

Thanks in advance.

View 1 Replies View Related

Sql Query Fails At Specific Times

Dec 11, 2003

Hi,

I'm in an unfortunate situation. We are posting information using a stored procedure to an outside SQL server connected to through a System DSN on our server (win 2003 server) using php's ODBC functions (we never had any luck connecting directly to the SQL server using php's mssql functions).

Everything is working fine, we can connect, send querys, etc ... but between 1am and 10am we recieve errors when trying to execute queries (though we can connect fine).


Whoops ... forgot to get the error returned before it turned 10am ... I can post it tomorrow


I think the database is being locked, but unfortunately I know very little about MS SQL server

The people who's database we are connecting to are not being helpful ... I was hoping I could get some suggestions on what would be the cause.

Anything you can suggest would be a huge help! Thanks!
- Joe

View 2 Replies View Related

Query Analyzer Cannot Connect, Times Out

Nov 19, 2004

We are having a problem with Query Analyzer not connecting to SQL Server anymore. Sometimes it will, sometimes it won't. Sometimes when it does, then you click on the databases drop-down, it may take a long time to return. Likewise, it may take a long time to open the object browser, or it may open without the database info but with just the "Common Objects" info.

All of this used to work just fine.

HELP

View 2 Replies View Related

Baffling Query Return Times

Feb 11, 2008

Simple version first:

The basic question is:

what would cause? this query takes minutes or times out:

select xx,xx,xx,xx
from view_xxx
where field in
(

select distinct xxx from table inner join table.....
)


the inner query
select distinct xxx from table inner join table..... takes less than a second

then if I take the results of that query and do this:

select xx,xx,xx,xx
from view_xxx
where field in
(

52193,23523,25233... and so on
)

this later query takes 2 seconds... What is the difference? For more details see the detailed version.






-Robert


now a more details version:



On a SQL2000 machine...

What would cause this query to take forever, or even timeout:


Select distinct VTR.Control_ID from View_ToolResults VTR

Where VTR.Control_ID in

(

------ NOTE INNER QUERY TAKES LESS THAN 1 SECOND
SELECT ORD.CONTROL_ID

FROM Orders ORD

INNER JOIN Providers PR ON PR.SUBJECT_ID = ORD.SUBJECT_ID and PR.SV_OFFICE_ID = ORD.SV_OFFICE_ID and PR.Source_ID = ORD.Source_ID

INNER JOIN VisitTypes VT ON ORD.VISIT_TYPE_ID = VT.VISIT_TYPE_ID and ORD.Source_ID = VT.Source_ID

INNER JOIN HealthPlans HP ON HP.MARKET_ID = ORD.MARKET_ID and HP.Source_ID = ORD.Source_ID

INNER JOIN HPGroups HPG ON HP.MARKET_ID = HPG.MARKET_ID AND HP.SOURCE_ID = HPG.SOURCE_ID WHERE (ORD.Status is not null AND ORD.Status <>'E')

AND HPG.GR_ID in

(

SELECT GR_ID from UserHPGroups Where User_ID= 7

)

AND ORD.RELEASED_DATE between '01/01/2001' and '02/11/2008'

and ORD.RECEIVED_DATE between '07/01/2007' and

'12/31/2007' and ORD.MARKET_ID= 2699431


)

as mentioned above the inner query takes less than 1 second. So if I take the results from that query and do a select like this:


Select distinct VTR.Control_ID from View_ToolResults VTR

Where VTR.Control_ID in
(55836
,55631
,55331
,50992
,51101
,51196
,51500
,52269
,52366
,52384
,52429
,52518
,53117
,53993
,53994
,53995
,54027
,54128
,54192
,54264
,54291
,54292
,54324
,54379
,54578
,54706
,54917
,52622
,54354
,55965
,55410
,55461)

It takes 2 seconds.....

WHAT!!!!!>???!?!?! i don't understand... what is the difference?

The field in all cases is declared as Numeric(10,0)... I've tried to convert to int. I've tried to do temp tables... it doesn't help.

View 10 Replies View Related

SQL Datasource Running The Same Query Mutliple Times

Jan 22, 2008

I have multiple SQLDatasources on multiple pages. When I call the Select command for the datasource the query is run multiple times. I was wondering if anyone had any problems like this. The data is being read into listboxes. If you need any more info or have any specific questions, feel free to ask.

View 6 Replies View Related

Employee Attendance With In/out Times (was Query Help Needed...)

Apr 8, 2006

Dear Friends,
I am in problem & have to solve one query.
I have a one table with the employee time in & time out data, employee can go out & come in fequently in a day.

I want to know that how much time every emp have attend in the company per day.

Kindly, do reply as soon as possible.

I am enclosing data defination in txt file along with the data in the MS Excel file.

Thanx ....

View 7 Replies View Related

Transact SQL :: Running Query For Multiple Times Through The Day?

Jun 12, 2015

I want  the below query to run 24 hours ..once the insert is complete, run again , so on for 24 hours .

there is a way to run every second in as job but i want to run only after run complete ..is there a way to run the query after every complete run ? and keep in job 
 
INSERT INTO [dbo].[Audit_Active]
([SPID],[LoginName],[HostName],[ProgramName],[Command],[LastQuery],[DBName],[ServerName])
 SELECT   
--DISTINCT  
p.SPID,
p.LogiName,
p.HostName,   

[Code] ....

View 8 Replies View Related

SQL Query Required

Mar 23, 2000

I have a table

Table1
------

StudentId Class Test1 Marks1 Test2 Marks2 Test3 Marks3
---------------------------------------------------------------------------
1 1 1 50 3 35 5 40
2 1 1 50 4 40 7 43
3 2 1 47 3 50 6 42


I would like to Insert this data into another table in this form

Table2
------

StudentId Test Marks
---------------------------
1 1 50
1 3 35
1 5 40
2 1 50
2 4 40
2 7 43
3 1 47
3 3 50
3 6 42


Can you write a SQL Query to accomplish this.

Thank you

View 1 Replies View Related

Help With Query Required...

Jul 20, 2005

I have two related tables in my SQL database that I wish to join as follows:------------------------------------tblCustomersID (pk)Nameetc.tblCustomerManagersID (pk)CustomerID (fk)Manager (this *is* an fk but for the purposes of demonstration isnot)StartDate (indicates the date upon which the manager took / is takingcontrol of the company)------------------------------------Example entries are:tblCustomers1 Microsoft2 Symantec3 BorlandtblCustomerManagers1 1 Barry 01/01/032 1 Peter 01/07/033 2 Norman 01/02/034 3 Terry 01/01/035 3 Peter 01/07/05------------------------------------What I want to do is extract, in one query, a list of all customers andtheir *current* associated manager, so the result set today would be:Microsoft Peter 01/07/03Symantec Norman 01/02/03Borland Terry 01/01/03Currently I have:SELECT [Name], [Manager], [StartDate]FROM tblCustomersINNER JOIN tblCustomerManagers ON tblCustomerManagers.[CustomerID] =tblCustomers.[ID]WHERE [StartDate] <= GETDATE()ORDER BY [Name], [StartDate] DESCbut this obviously returns multiple entries for customers having managersprior to today eg:....Microsoft Peter 01/07/03Microsoft Barry 01/01/03....I know this is a simple question but I cannot think of a way of doing itwithout making the query extremely complicated.Any help is appreciated,Thanks,df

View 2 Replies View Related

Help Required In A Query !

Jan 29, 2008


Help me in achieving a query €¦

My table look like

col1 col2
-------------------
a 1
a 2
a 3
b 1
b 2

and I want the output as€¦

col1 col2 col3 col4
----------------------------------------
a 1 2 3
b 1 2

The col2 values should be populated as different columns for the col1 value

Thanks
J


View 3 Replies View Related

SQL Server 2008 :: Iterate Query Using A Loop As Many As 5 Times Max?

Mar 20, 2015

If exists (select fieldID from #tmploginfo where status <> 0
group by fieldID
having count(*) > 0)
begin
backup log rdb to disk = N'C:
db1.trn'
End

I want to iterate this query using a loop as many as 5 times max.

View 3 Replies View Related

Help Required For The Select Query :-(

May 18, 2008

Hi i'm developing a website for my final year project with ASP.net and SQL Server 2005 databse. The problem i'm facing since last week is that, i'm unable to use "Select" query to fetch the data from my SQL Server database.
 i've used the following code to INSERT the database which is successfull.SqlDataSource sample= new SqlDataSource();
sample.ConnectionString = ConfigurationManager.ConnectionStrings["ConnectionStringName"].ToString();sample.InsertCommandType = SqlDataSourceCommandType.Text;
sample.InsertCommand = "INSERT INTO Table_Name(Fields) VALUES (@Fields)";
sample.InsertParameters.Add("Fields", FieldsTxtBox.Text);
 
 int row = 0;
try
{
row = sample.Insert();
}catch (Exception ex)
{
// Response.Redirect ("Failed.aspx");
Label1.Text = ex.ToString();
}
finally
{sample= null;
}if (row != 0)
{Response.Redirect("Success.aspx");
}
else
{Response.Redirect("Failed.aspx");
}
 
 
It successfully updates my database fields. I've tried many codes that i've found over the internet but none worked. can anyone please tell me how to use SELECT query in the fashion as the above one?
I shall be very thankfull for the help.
Regards,
Jigzy

View 3 Replies View Related

InSQL 7.1 - Count How Many Times A Tag Equals 1 Over A Specified Time Period Query....

Aug 2, 2007

Need help to create a query to count how many times over a specified time the tag(s) equal the value of 1.

Thanks

Gary

View 3 Replies View Related

Query Correction Required Urgent

May 25, 2008

Hi All,

First of all its very very urgent. Secondly I am not an expert.

Now here is my problem.

I want to loop through my html files and want to save the data in my table column. here is the Code which need correction.

CODE:
USE [AdventureWorks]
DECLARE @cmd varchar(1000);
DECLARE @FileName varchar(100);
DECLARE @FilePath varchar(100);
SET @FileName = 'C: est'+@FilePath+'html';
SET @cmd = 'INSERT INTO myTable(FileName, FileType, Document)' +
'SELECT ' + @FilePath + ', FileType,
* FROM OPENROWSET(BULK @FileName, SINGLE_CLOB) AS Document'

EXEC (@cmd);
Select * from myTable

Just for practice I am using Adventureworks db. I am using SQL Express 2005.

My html files are named something like this:

AC0234.html
DB9803.html
CG4571.html

I cannot change my file names.

Thanks in advance.

Regards;

View 2 Replies View Related

Calculating Positions Query Required...........

Aug 31, 2006

AA Guyz i want to calculate class position of students from a table.Sample data is as follows...Roll # - Name - Marks1 - ABC - 602 - DEF - 603 - GHI - 574 - JKL - 555 -MNO - 506 -PQR - 53The query should return the following result.Roll # - Name - Marks - POSITION1 - ABC - 60 - 12 - DEF - 60 - 13 - GHI - 57 - 34 - JKL - 55 - 45 -MNO - 50 - 56 -PQR - 53 - 6I want query in MS SQL Server 2000

View 1 Replies View Related

Help Required Please + SQL Server 2005 + LIKE Query

Jan 10, 2008


Hi Guys

I am in need of some assistance please.

I am using SQL Server 2005 and C#(winforms).

For example if I have a winform with a textbox and search button. If I type in ABCD1234. I won't know what the data is coming into the X Table. So there will be hundreds of description data in the description field in X table.

So in the X Table, there are ABCD1234,ABCD_1234,ABCD/1234,ABCD 1234

But I will only pick this 'ABCD1234' record up, and the rest won't be picked. They are variations of the same description. It needs to pick also ABCD_1234,ABCD/1234,ABCD 1234

If also type in 5678, in another column like code in X Table. It would have 005678,05678,56780. But I will only pick this '5678' record up, and the rest won't be picked. They are variations of the same code.
It needs to pick also 005678,05678,56780

I have tried LIKE, FREETEXT and CONTAINS.

But another idea is a table of alternate descriptions for those that you know about and look those up and search for them all. But how can that be done?

Any ideas guys please? with examples if possible.

Thanks Newbie.....

View 4 Replies View Related

To Get Only Required Records - Select Query Help

Jul 19, 2006

I have records which are like below.


create table testedit
(
editid int
,Tguid varchar(20)
,ttime numeric(4,2)
,numApp int
,numOrg int
,custid varchar(1)
)

INSERT INTO testedit values(1,'ABC',12.52,40,11,'Z')
INSERT INTO testedit values(2,'ABC',12.52,500,33,'Z')
INSERT INTO testedit values(3,'ABC',12.53,500,33,'Z')

Out of this records I would like to select only the 1st and the 3rd record. ie. My result should only have the below rows

1,'ABC',12.52,40,11,'Z'

3,'ABC',12.53,500,33,'Z'

Any help?










View 6 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved