Vote Query Logic Selection
Jun 3, 2006
Hello,
I have a requirement to select millions of rows from table and need do some parsing each row. I have identity column on each table.
Here is the query logic I'm following.
Logic A:Uisng While loop processing data row by row
Logic B: Using Cursor Processing row by row
Here is the perormance on the above ran against .5 millions rows of data.
Logic A: Logic B:
CPU usage 564254 464511
Duration 18 15
The above result after completion of the data
The below is from query analyser
Estimated query Cost 21% 79%
Can we trust Estimated query cost? and Which logic you will choose use?.
View 1 Replies
ADVERTISEMENT
Jul 23, 2005
Vote for or against a new newsgroup proposal.To summarize what you need to do, just send an empty e-mail toJoin Bytes!You'll receive a ballot by e-mail. Follow the instructions and vote.__________________________________________________ _____________________FIRST CALL FOR VOTES (of 2)unmoderated group comp.databases.postgresqlNewsgroups line:comp.databases.postgresql PGSQL Relational Database Management System.Votes must be received by 23:59:59 UTC, 9 Apr 2005.This vote is being conducted by a neutral third party. Questions aboutthe proposed group should be directed to the proponent.Proponent: Mike Cox <mikecoxlinux@yahoo.com>Votetaker: Bill Aten <bill@netagw.com>RATIONALE: comp.databases.postgresqlTo provide a Big-Eight usenet group for users of the PostgreSQLRelational Database Management System. Currently there are mailinglists gated to the public pgsql.* hierarchy. Issues with mailinglist gateways, and the much larger distribution of the Big-Eighthierarchy make it extremely desirable to have a PostgreSQL groupin the Big Eight.CHARTER: comp.databases.postgresqlThe newsgroup comp.databases.postgresql is a usenet discussion groupfor the PostgreSQL Relational Database Management System. Topicsof discussion may include:GENERAL* General discussions of PostgreSQL.* Assisting beginners in using the PostgreSQL Relational DatabaseManagement system.* Help answer basic questions.ADMINISTRATION* Discussions pertaining to the administration, compilationand installation of PostgreSQL.* Announcements of new versions of PostgreSQL, PostgreSQLrelated software, and documentation.* Administration of PostgreSQL interfaces, including JDBC and ODBC.* Administration and installation of the Contrib packages.* Using PostgreSQL Point in Time Recovery.* Startup scripts, or scripts that automate PostgreSQL related tasks.DEVELOPING WITH POSTGRESQL* Programming using PostgreSQL.* Developing with PostgreSQL interfaces, including JDBC and ODBC.SCALABILITY* PostgreSQL performance, benchmarking and related topics.* How to use Replication in PostgreSQL.* Hardware, Software configurations and recommendations for optimalPostgreSQL operation. Examples are x86-64, NUMA, etc.SECURITY* Announcements of patches that fix vulnerabilities.* PostgreSQL Best practices to design and keep PostgreSQL secure.* SSH, SSL, and the Crypto Contrib packages.SQL* Normalization and theory as it applies to PostgreSQL.* Transactions, Indices, Cursors, Triggers, and Nested Transactions.* PostgreSQL specific topics such as Objects.END CHARTER.HOW TO VOTE:In order to vote on this proposal you will first need to request aregistered ballot. This is accomplished by sending an email to theaddress specified below from the email account that you intend to usewhen you submit the ballot for processing. The Subject: and body ofthe message does not matter. They can both be blank (preferred) ifyour software will allow that.PLEASE, do not send this entire message back to me as this mail isarchived.Mail your ballot request to: <postgresql-ballot@netagw.com>Just "replying" to this message should work, but check the "To:" line.When your email message is received, a reply message will be sent toyou with further instructions regarding how to vote. You will alsoreceive a copy of the CFV which will contain a ballot that isregistered for use only for this CFV, and only when submitted from theexact same address that originally requested it.IMPORTANT VOTING PROCEDURE NOTES:Standard Guidelines for voting apply. Only one vote per person, nomore than one vote per account. Votes must be mailed directly fromthe voter to the votetaker. Anonymous, forwarded, or proxy votesare not valid. Votes mailed by WWW/HTML/CGI forms are consideredto be anonymous votes.Vote counting is automated. Failure to follow these directions maymean that your vote does not get counted. If you do not receive anacknowledgment of your vote within three days, contact the votetakerabout the problem. It's your responsibility to make sure your voteis registered correctly. Duplicate votes are resolved in favor ofthe most recent valid vote. Names, addresses, and votes of all voterswill be published in the final voting RESULT posting.DO NOT redistribute this CFV in any manner whatsoever. The purpose ofa Usenet vote is to determine the genuine interest of persons who wouldread a proposed newsgroup. Soliciting votes from disinterested partiesdefeats this purpose. Only the votetaker, the news.announce.newgroupsmoderator, and the proponent (if specifically authorized by thevotetaker) are permitted to distribute copies of this CFV.Distribution of pre-marked or otherwise modified copies of this CFV isgenerally considered voting fraud and should be reported immediately tothe votetaker or the UVV <contact@uvv.org>. In cases where voting fraudis determined to have occurred, it is standard operating procedure todelete ALL votes submitted by the violator. When in doubt, ask thevotetaker.DISTRIBUTION:The only official sources for copies of this CFV are the locationslisted below, the UVV web site at http://www.uvv.org/, and thevotetaker's e-mail CFV server which can be reached at<postgresql-cfv-request@netagw.com>.This CFV has been posted to the following newsgroups:news.announce.newgroupsnews.groupscomp.databasescomp.os.linux.misccomp.unix.bsd.freebsd.misc
View 14 Replies
View Related
Mar 16, 2007
Anyone who has installed SP2 will notice that RS now adds in the auto "Select All" on multi-value parameters. This was removed with SP1 but its back, and its causing me and other developers a lot of trouble as we have created custom "Select All" option in multi-value paramters to address the removal of it in SP1.
Why dont MS make this auto "Select All" configurable, it should be an option, but its not.
If this is a problem for you then vote for the issue here....maybe if MS sees thats it is a big issue they may include a fix in a hotfix.
https://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=249227
View 1 Replies
View Related
Jul 28, 2005
I have 2 tables:
First table: empID,PlanID,groupID
Second: PlanID,groupID,EffectiveDate,TerminationDate,DeadlineDate
I need to show only employee with in spesific group who is not
enroll for the current month until deadline passed.
Example:
empID PlanIDgroupID
11012
PlanIDGroupIDEffectiveDate TerminationdateDeadlineDate
101208/01/200508/31/200508/15/2005
111209/01/200509/31/200509/15/2005
91208/01/200508/31/200508/15/2005
If I run it today I should not get any results back. If I run in
on 8/15/2005 I should get back data with palnID11.
View 1 Replies
View Related
Jun 8, 2007
I have some table data and know how I want the results but I'm just having a bit of trouble in constructing the SQL logic to obtain the desired results. There's a site where visitors are able to select from a list of parts, and it will return a set of model/products that they can produce with the selected parts. Here's the data ...
tblModel tblPart
ModelId ModelName PartId PartName
---------------------- ----------------------
1 Alpha 1 CHOO1 Stem
2 Bravo 2 BH034 Rod
3 Bravo Pro 3 HRE Seat
tblModelPart
ModelPartId ModelId PartId
---------------------------------
1 1 1
2 2 1
3 2 3
4 3 1
5 3 2
6 3 3
... and here's the logic that I'm trying to implement, assume that the user selects from a form, parts with the PartId 1 and 3 ...
1. Return all models that contain only the parts selected.
ModelId ModelName
---------------------
2 Bravo
2. Return all models that contain the parts selected, and may contain other parts.
ModelId ModelName
---------------------
2 Bravo
3 Bravo Pro
... so do you have any idea on how the SQL would look for either of these queries?
Thanks in advance,
Goran
View 8 Replies
View Related
Mar 20, 2008
I have two tables X,Y
X
empno....Sal.....Tax.....Returns...name
1.....4500....1050.... 750.......robert
2.....5750.....1560....900.......john
3.....4000.....900.....600.......keen
4.....6100....1200.....1000......stauton
Y
empno....Sal.....Tax.....Returns...name
1.....4500....1000.... 000.......robert
2.....5750.....1200....900.......john
3.....4000.....900.....600.......keen
4.....6100....1000.....1000.......stauton
If you see the above tables I have data mismatch in X and Y tables for the same empno.
I need to write a query which shows emp no and columns(name of col) where the data mismatch has occured.
I came up with a query which I have to write for every individual column to get the mismatch.
Since there 120 columns it is pretty hard task..i m looking for a logic where I can write a query which shows mismatched data in columns.
Expected Output
table z
col1..col2
1......tax
3......tax
Appreciate your help.
View 5 Replies
View Related
Apr 14, 2008
Hi, sorry for a newbie question but I was wondering if the following is possible:
I have to select some information from a table which I have already created a query for. This information then has to be inserted into a new table but needs another column (not the promary key) with another unique custom identifer for each record in the format EX01 which is incremented by 1 for each record. I was wondering how is it possible to do this?
My approach was to create a view and then insert the values form the view into the new table but I still have no idea how to do the unique identifer. Was the first part of my approach correct or have been wrong from the start?
View 3 Replies
View Related
Sep 21, 2006
Hi All
Being new to this forum and to SQL, I would to apologise upfront for my clumsy code and explanations as I try and get to grips with this subject.
I have created this query which does work:
SELECT T1.U_Serial,
case
when (U_RDate < GETDATE() AND U_ASDate Is NULL)
then 'NA'
when (U_RDate Is NULL)
then 'No Request'
when (U_ASDate Is Not NULL And U_AEDate Is NULL)
then 'NA'
when (U_ASDate Is Not NULL And U_AEDate Is Not NULL)
then 'A'
when (U_RDate > GETDATE() AND U_ASDate Is NULL)
then 'NA'
else 'DN'
end As Available,
case
when (U_RDate < GETDATE() AND U_ASDate Is NULL)
then 'Late'
when (U_RDate Is NULL)
then 'No Request'
when (U_ASDate Is Not NULL And U_AEDate Is NULL)
then 'Busy'
when (U_ASDate Is Not NULL And U_AEDate Is Not NULL)
then 'Done'
when (U_RDate > GETDATE() AND U_ASDate Is NULL)
then 'Waiting'
else 'DN'
end As Progress,
T1.U_Status,T1.U_JobTp, T1.U_JobNr,T1.Code, T0.U_CardNM, T0.U_ZpCd, GETDATE() as Today, T1.U_RDate, T1.U_ASDate, T1.U_AEDate, T1.U_ItemCd, T1.U_ItemDsc
FROM [dbo].[@IDH_JOBENTR] T0 , [dbo].[@IDH_JOBSHD] T1
WHERE T0.Code = T1.U_JobNr AND T1.U_Serial not like ''
ORDER BY T1.U_Serial, T1.U_AEDate DESC, T1.U_JobNr DESC ,T1.Code DESC,Today, T1.U_RDate, Available, Progress, T1.U_Status,T1.U_JobTp,T0.U_CardNM, T0.U_ZpCd, T1.U_ASDate, T1.U_ItemCd, T1.U_ItemDsc
The tables I’m using are IDH_JOBENTR which is the header records for my jobs and IDH_JOBSHD, which holds the row details for the jobs.
I’m trying to extract from the IDH_JOBSHD table the last (row) detail record for the (header) job.
The way the query works now, the first row for each unique serial number is the record I need, but this is all the info I would like to display I don’t need the other lines, and I don't know how to strip out the rest of the data
I hope this make sense.
Kind regards
Hayden
View 7 Replies
View Related
Sep 14, 2006
I have a little system of 3 tables Job, employees and times. This times table has the fields times_id, employee_id and job_idI'm trying to have a query that pull of employees that don't have a certain job_id yet. I'm going to put this data in a table so the user knows they are available for that job. The code i have isn't working, and i'm not sure why.SELECT DISTINCT times.employee_id, employee.employee_nameFROM employee INNER JOIN times ON employee.employee_id = times.employee_id WHERE (times.job_id <> @job_id) Thanks in advance for any help. I'm sure I missing someting silly, or maybe i need to have a stored procedure involved?... Thanks!
View 3 Replies
View Related
May 25, 2007
Hi All
I have a sqlserver database with product, catagory and sub catagory format. Before I describe my problem, let me share whats I have in db. Their are two types of sinaros, either the products are directly assigned to a catagory or a product is placed in subcatagory that is in turn have a catagory. I use the following table struct for both of the scenarios:
Product>>subcat bridge>>subcatagory
Product>>catbridge>>catagory
Here are the queries to get them:
1. If product assinged direct in catagory then
select product.pid, product.Prd_heading,product.[Description], product.Brand, product.img from product,cat_bridge,category where product.id=cat_bridge.pid and cat_bridge.catid=category.catid;
2. If product assinged to sub cat then
select product.pid, product.Prd_heading,product.[Description], product.Brand, product.img from product,subcat_bridge,subcategory where product.pid=subcat_bridge.pid and subcat_bridge.subcatid=subcategory.subcatid and subcategory.catid=category.catid;
Now the problem is, I want to use a single query to download all the products to a CSV format and I need to combine both of the queries with a single one, probably with if else logic, but I am not getting it, I mean how to acheive. Can anyone help me sort this out?
Thanks in Advance
Regards
Mykhan
View 5 Replies
View Related
Jan 25, 2006
I am dealing with two tables and I am trying to take one column from a table and match the records with another table and append the data of that column.
I used an update query that looks like this:
UPDATE Acct_table Set Acct_table.Score =
(Select Score_tbl.Score from Score_tbl
Where Acct_table.Acctnb = Score_tbl.Acctnb
This process has been running for over an hour and a half and is building a large log file. I am curious to know if there is a better command that I can use in order to join the tables and then just drop the column from one to the other. Both tables are indexed on Acctnb.
Any insight would truly help.
Thanks!
View 4 Replies
View Related
Apr 14, 2008
Hi, sorry for another newbie question but I was wondering if the following is possible:
I have to take some information from a table which I have already created a query for. This information then has to be inserted into a new table but needs another column (not the promary key) with another unique custom identifer for each record in the format EX01 which is incremented by 1 for each record. I was wondering how is it possible to do this?
My approach was to create a view and then insert the values form the view into the new table but I still have no idea how to do the unique identifer. Was the first part of my approach correct or have been wrong from the start?
Thanks for any help.
View 1 Replies
View Related
Mar 29, 2005
Hello,
I wonder if someone has come across a similar problem I am having.
I am migrating a database from Access to MS SQL 2000. The tables imported fine, but the queries had to be rewritten. I placed them under "Views". At present I am able to run a query directly on the SQL server, and it populates all fields nicely.
When I do "SELECT * FROM EQCustomerReport" where EQCustomerReport is a name of a View on SQL, it only returns part of the fields. The other fields are blanked out for some reason.
Please tell me if I am making a common mistake or something. Should I be using Stored Procedures instead of Views. Or would I be better of passing a full text of a query from my .NET application?
Thanks very much in advance.
Martyn
View 3 Replies
View Related
May 29, 2007
I'd like to make a logic statement, that would take as arguments result of the sql select query. In more details: I would like to create a local Bool variable that would be false if some value is NULL in the table (or select query).Query example:select taskID from Users where Login=@usernameWhich classes/methods should i use to solve this problem? I use SqlDataSource to get access to database and i think i should use something like SqlDataSource.UpdateCommand and SqlDataSource.UpdateParameters but dont know how to build from this a logic statement.Thanks in advance
View 8 Replies
View Related
Mar 28, 2008
Table:GRoupAllocation
______________________
GroupId (Primarykey)
GroupName
TableystemAllocation
_______________________
SystemId(Primarykey)
SystemName
GroupId (foreignkey)
TableeviceAllocation
_______________________
DeviceId (Primarykey)
DeviceName
SystemId (foreignkey)
_______________________
TableensorAllocation
_______________________
SensorId (Primarykey)
SensorName
GroupId (foreignkey)
SystemId (foreignkey)
deviceid(foreignkey)
_______________________
Table:GRoupAllocation
______________________
GroupId GroupName
1 Group1
2 Group2
3 GRoup3
4 Group4
TableystemAllocation
___________________________
SystemId SystemName GroupId
1 system1 1
2 system2 2
3 system3 3
4 system4 2
5 system5 1
TableeviceAllocation
___________________________
DeviceId DeviceName SystemId
1 Device1 1
2 Device3 3
3 Device4 2
TableensorAllocation
____________________________________________
SensorId SensorName GroupId SystemId DeviceId
1 sensor1 1 1 1
3 sensor3 2 2
4 sensor4 3 3 3
my results should be like this:
Results:
___________________________________________________________________
GroupName SystemName DeviceName SensorName
___________________________________________________________________
Group1 system1 Device1 sensor1
Group1 null null sensor2
GRoup2 system2 null sensor3
GRoup2 system4 null null
Group3 system3 Device3 sensor4
Group4 null null null
so i need to populate the results in treeview.my treeview looks lika this:
Group1
|____System1
|________Device1
|_______sensor1
|_______system5
Group2
|____System2
|________Device1
|_______sensor1
|____System4
|____Device4
like this i need to populate. i need to show all the groupname and belonging systemName and belonging devicename and belonging sensorname
so please give me query for this complex operation please
criteria's
1.GRoup can have systems and system can have devices and device can have sensors
2.GRoup can have systems and systems can have sensors[no device]
3.GRoup can have systems and systems can have devices [no sensor]
4.GRoup can only have system [no device, no sensor]
5.GRoup can have only sensor[no system, no device]
so please give me query for this. not stored procedures.i need query for this
View 3 Replies
View Related
Sep 16, 2006
I add a new table and I want to see it in my list, I can go to EM and refresh there but it appears I have to close QA in order to see the new table. Is there a refresh option in QA to see my new object?
thx,
Kat
View 1 Replies
View Related
Aug 7, 2007
i will try to explain what i want with an example
if have a query that returns
user code amount
user1 A 10
user1 B 100
user1 C 10
user2 B 50
user2 D 10
user3 A 10
user3 C 20
what i want in my report is the following as result
Sum of code A and C Sum of code B and D
user1 20 100
user2 60
user3 30
so can you make variables on the scope user that do a selection on the 'code'
in words like a variable that give me the sum of the amount where code in A and C in the scope user
View 3 Replies
View Related
Aug 20, 2004
I have a perl program that is looping through a hash of a hash. I need to Update any existing records but also insert any new records in the table using collected data in the hash.
Life would be very simple if it was possible to use a Where Clause in an Insert statement but not does not work.
Here is some example code from my program:
sub Test{
foreach my $table(keys %$HoH){
foreach my $field(keys %{$HoH->{$table}}){
if($table eq "CPU"){
my $CPUstatement = "INSERT INTO CPU(CPUNumber, Name, MaxClockSpeed, SystemNetName)
Values ('$field',
'$HoH->{CPU}{$field}{Name}',
'$HoH->{CPU}{$field}{MaxClockSpeed}' ,
'$HoH->{Host}{SystemNetName}')";
print "$CPUstatement";
if ($db->Sql($CPUstatement))
{
print "Error on SQL Statement";
Win32::ODBC::DumpError();
}
else
{
print "successful";
}
}
}
}
}
Thanks,
Laura
View 5 Replies
View Related
Nov 25, 2005
have a SQL2K/VB.NET05 -based website that uses a complex search query, whose results will contain additional logic to be evaluated. There are thousands of records and growing, so it is not feasible to code this within the program...it must be evaluated inline or after the query, and it is also not feasible to set up additional fields and tables to handle the logic.
For a very general example: In the .NET code, the following variables are recognized:
sex="M"
Paid=4350.00
Outstanding=28000.50
One of the query result fields will contain the additional logic to evaluate and another will tell the type of expression..
EVAL EXPR
BOOL Sex='F' and Paid/Outstanding < 27.50
BOOL Sex='M' and Paid/Outstanding < 38 or Sex='F'
INT Paid*52.33
In other words..the thousands of records being returned have their own additional logic to evaluate. Is there a way this can be done by importing the variable into SQL server and testing it during the query?
If not, is there a way that I can run the code in the middle of .NET? I know I could run scripted code while in ASP, but ASP.NET is compiled, so I dont know if it can be done there....
View 3 Replies
View Related
May 25, 2015
I have a below query which have a date filter like "EST_PICK_DATE between '2015-02-01' and '2015-06-01'", where the logic is EST_PICK_DATE should be 3 months from the current month and 1st date of next month. Ex for current month MAY, EST_PICK_DATE shoulc be between '2015-02-01' and '2015-06-01'. I need to write below query dynamically. In below query i have hardcoded the value ("EST_PICK_DATE between '2015-02-01' and '2015-06-01'"), but it should take dynamically. How to achieve this?
I am using this query in SSIS package, So Shall i do in SQL level or we should implement this logic in package? If yes, How?
INSERT INTO STG_Open_Orders (Div_Code, net_price, gross_price) SELECT ord.DIV_CODE AS Div_Code, ord_l.NET_PRICE AS net_price, ord_l.gross_price AS gross_price, FROM ORD ord inner join ORD_L ord_l ONord.ORD_ID=ord_l.ORD_ID WHERE ord_l.EST_PICK_DATE BETWEEN '2015-02-01' AND'2015-06-01'
View 1 Replies
View Related
Dec 22, 2014
I have a SSRS report with 6 columns each column containing count of total# of applicants meeting certain criteria.
User want to click on each column and see the basic information and also want to get the ability to export the data into excel.
I know that I can create 6 drillthrough reports with basic information of applicants and link it to the count from each column respectively but I was wondering if it is possible to write a Stored procedure with all 6 select queries and execute only 1 select query based on the column that user clicks on main report ?
View 0 Replies
View Related
Jun 23, 2006
Hello,I have 2 tables:- Customers with columns:customerID(prim_key),customerName(with customer's names)- Deliveries with columns:deliveryID(primKey),sender(ref_key to CustomerID from Customers),receiver(also ref_key to CustomerID from Customers);I need to select all data about deliveries, but instead of havingsender's ID and receiver's ID, I need to have their Names.I tried to do:SELECTdeliveries.deliveryID,Customers.customerName AS sender,Customers.customerName AS receiverFROMcustomers, deliveriesWHERECustomers.customerID=Deliveries.sender ANDCustomers.customerID=Deliveries.receiver;But this only works if sender=receiver, which is obvious ;)I'd like to know if there is any other way for obtaining those datawithin one queryThank you very much for your helpChris
View 2 Replies
View Related
Nov 20, 2015
I have a report that prompts the user to select a parameter, for simplicity, let's say the parameter is for color choice, options are Red, Yellow, Blue or *. The * is for include all colors. I am passing that parameter back to the dataset query which, again for simplicity is
select
Hue from AvailableColors
whereColor
= @ColorParam.
For a specific color this works fine, for the "*" selection it returns a null. It would seem that I need to convert the * to % but I am not sure how.....
View 6 Replies
View Related
May 10, 2008
Can anyone see where my logic may have gone a stray?
A user would be attempting to update a gridview row, I'm storing the amount of an item and the qty they purchased. If the order was for $150 and the grid has two item 1 x $50 and 2 x $50 the order already totals $150, so if the user tries to change the first item to a qty of 2 x $50 the total would be $200 and this would be more than the total payment or $150.
I want to then tell them they cannot do this.
@AP_ID Int,@AI_ID int,@PurchaseAmount money,@PurchaseQTY int,@LastUpdate datetime,@LastUpdateBy nvarchar(50),@Receipt_ID intASdeclare @current_item_total decimal(18,2)declare @new_item_total decimal(18,2)declare @total_payments decimal(18,2)declare @current_purchase table(receipt_id int,purchase_amt money)INSERT INTO @current_purchase SELECT tblPurchase.Receipt_ID,(tblPurchase.PurchaseAmount * tblPurchase.PurchaseQty) as purchase_amtFROM tblPurchase INNER JOIN tblReceipts ON tblPurchase.Receipt_ID = tblReceipts.Receipt_IDWHERE tblReceipts.Receipt_ID=@receipt_id--Get total already saved to recordselect @current_item_total = sum(purchase_amt) from @current_purchase--Get total amount of payment saved to recordselect @total_payments = sum(tblReceipts.AmountPaid) from tblReceipts where tblReceipts.receipt_id=@receipt_id--Get total amount user is trying to save to recordset @new_item_total = (@PurchaseAmount * @PurchaseQTY)--If current total plus new total is greater than total payment, tell user they cannot do this.IF ((@current_item_total + @new_item_total) > @total_payments)BEGINSELECT 'You are attempting to add more than your total payment.' AS MESSAGEENDELSEBEGIN--UPDATE ROWUPDATE tblPurchase SET [AI_ID]=@AI_ID,[PurchaseAmount]=@PurchaseAmount,PurchaseQTY=@PurchaseQTY,LastUpdate=@LastUpdate,LastUpdateBy=@LastUpdateBy WHERE [AP_ID]=@AP_ID SELECT 'Item was updated.' AS MESSAGEEND
View 2 Replies
View Related
Jan 6, 2004
Trying to bind some data to a datalist for a report.
User selects an Industry from a dropdown list and then I dump all records for that industry. However in order to parse some of the record field values into names (I.E. from a 1 to the actual company name) for some records I have to read TABLE_ONE and for other records I might have to read TABLE_TWO depending on the value of FIELD_ONE.
If FIELD_ONE = "A" then I get the NAME from TABLE_ONE.
If FIELD_ONE = "B" then I get the NAME from TABLE_TWO.
If FIELD_ONE = "C" then I get the NAME from TABLE_THREE.
I'm lost at how to get started on this. I thought about adding IF statements to my query but these won't work because I'm not passing in the value of FIELD_ONE ahead of time - it's part of the query. So I thought maybe I could do a pre-read and store all FIELD_ONE values in an ArrayList and pass these in as parameters, but the stored proc is only being called once - so that won't work.
Any thoughts on how I can do this?
View 2 Replies
View Related
Apr 27, 2006
tbl_one hv 8mil rows, tbl_2 have 8k rows...
if
select count(*) from tbl_one
where sub_col1 = 2
return 3mil rows
and
select count(*) from tbl_2
where ad_col1 = '000009'
return 4k rows
HOW COME..
select count(*) from tbl_one,tbl_2
where (sub_col1 = 2 and ad_col1 = '1234')
return more than 12 billion rowss?? helpp..
View 7 Replies
View Related
May 3, 2006
I have to write trigger to relate two table.
If I have made changes like insert, update and modify in one table1 automatically have to change the table2 and vice versa.
How this can be done, do we need to point the common key fields in both table while inserting
View 8 Replies
View Related
Jun 12, 2007
What i'm trying to do is if this column dt.IN_DIV_NO is populated take that value first if it's null than rr.AIQ_R_DIVISION_NO and if that column is null than rr.F_DIVISION_NO.
This is what i came up with, will it evaluate the way i need it to?
case When dt.IN_DIV_NO is not null then dt.IN_DIV_NO else case when rr.AIQ_R_DIVISION_NO is null then rr.F_DIVISION_NO end end as Current_DIV
Thank-you
View 4 Replies
View Related
Mar 13, 2008
I have a logic problem,
I am selecting from a table
Select * from TAB_A
where state not in (1,4)
and create_date < '2008-01-01'
and
(
(x != 2 and y != 1 and z != 4) or
(x != 6 and y != 3 and z != 1) or
(x != 8 and y != 0 and z != 9)
)
then for example i am getting results where x,y and z is equal to one
or more of above combinations ?
Now i vaguely remember that using or with a != messes up the logic ?
if so can i use an NOR ? does it exist ?
View 5 Replies
View Related
Mar 25, 2008
I am looking for the best approach to update a table's column based on the results of two other different tables. My tables structure is as follows.
Table 1 has columns A and B (tblemployee has location and employeenumber )
Table 2 has columns C and A (tblocation has locationID (identity) and location)
Table 3 has coumns C and B (tblcountry locationID (foreign key) and employeenumber.)
I want to update Table 3 (tblcountry) with the new locationID if and employee changes location or gets miscoded using an SSIS package.
Thanks in advance.
View 7 Replies
View Related
Nov 14, 2007
I am having a little problem with my logic.
i have a table simplehoursassignment that has a field named br.
i need to get the value from simplehoursassigment & say if @mybit AND br > 0
set each day.
--CREATE PROCEDURE rpt_siteMealList(
-- (@cmb1 AS VARCHAR(100)) WITH ENCRYPTION
--)
--
--AS
DECLARE @dtm1 AS DATETIME
DECLARE @mybit AS INTEGER
SET @mybit=10
SELECT @mybit = CASE datepart(dw,@dtm1)
WHEN 1 THEN 1 -- 'Sunday'
WHEN 2 THEN 2 -- 'Monday'
WHEN 3 THEN 4 -- 'Tuesday'
WHEN 4 THEN 8 -- 'Wednesday'
WHEN 5 THEN 16 -- 'Thursday'
WHEN 6 THEN 32 -- 'Friday'
WHEN 7 THEN 64 -- 'Saturday'
END
SELECT br FROM simplehoursassignment
IF @mybit AND br > 0
BEGIN
CASE WHEN @mybit = 1 THEN 'Sunday'
WHEN @mybit = 2 THEN 'Monday'
WHEN @mybit = 3 THEN 'Tuesday'
WHEN @mybit = 4 THEN 'Wednesday'
WHEN @mybit = 5 THEN 'Thursday'
WHEN @mybit = 6 THEN 'Friday'
WHEN @mybit = 7 THEN 'Saturday'
END
END
View 3 Replies
View Related
Apr 30, 2008
I have this query that is returning the same result twice and i cannot find why. I only have one record in Subquote.
Does anyone know what the problem is?
Code Snippet
SELECT s.*
FROM Quote q
INNER JOIN SubQuote s
ON q.id = s.quoteID
INNER JOIN TakeOffSheetItem t
ON t.quoteID_takeoffitem = q.id AND t.subQuoteID_takeoffitem = s.subquoteid
INNER JOIN PipeGroup p
ON p.quoteID_PipeGroup = q.id AND p.subQuoteID_PipeGroup = s.subQuoteID
WHERE (q.id = 1
AND q.deleted = 0
AND s.deleted = 0
AND t.deleted_takeoffitem = 0
AND p.deleted_PipeGroup = 0)
ORDER BY s.subquoteid
Thanks
K
View 4 Replies
View Related
Oct 22, 2003
hello
in the database.....
table:1
DELIVERY_HEADER
INVOICE# PO#
1111 001,0002,0003
2222 005,0006,0007
in one invoice has many po# number i already get the po number individually using explode...
the ouput like this
001
002
003 and so on it is ok for that
but my problem is
i want to the po# should be selected i mean like a menu ..like the user select the which po# should be updated....
but i dont know how..
is there anyone can help me?
to elaborate more...
i can display the po# already without commas like in invoice# 1111
i can already display the po# number like this
001
002
003
after that i want it to be like a menu that user will only select the which po# should be updated..using arrow keys down and up....i mean just like selecting..
but i dont know how..
PLS HELP ME
thank
r3sann
View 1 Replies
View Related