I have a select like this: SELECT a.part_id, a.descript, b.location from PART_MASTER a, anotherdatabase.INVENTORY b where a.part_id = b.part_id Is it possible to use a @variable to identify the other database, rather than hard coding it? (I’ve tried @db2.INVENTORY b) but SQL SERVER 2000 doesn’t like that.
In a stored procedure, I’m storing the result of a select statement in @variable. Is there a way to capture a SQL Code 100, like Oracle’s SQLERRM(100)/ORA-01403 if no records are returned? I’m currently setting @variable = ‘*’ before the select and and IF @variable = ‘*’ afterwards, but there must be a more elegant [...]
I have a subfile that can be sorted by any of 4 fields, so I want to use imbedded SQL to read the data out of my PF in order to populate the subfile. I want to be able to allow the user to enter position to information, and position to that entry – normally, [...]
hi i am having three tables : state, agencydetail, parentdetaills i am running following queries but i am getting wrong result plz help me out where is the problem select state.state,count(ag.agencycode) as registag,count(ff.agencycode) as reportag,count(inp.regno) as incpwait,count(interp.regno) as intercpwait from state left outer join (select distinct agencycode,state from agencydetail) ag on state.state=ag.state left outer join [...]
In the middle of a large storage procedure I have a working SELECT 01 (see below) which at a couple of points uses CASE statement. I need to expand the most inner CASE to get SQL Server check for several values instead of one. Currently CASE I am talking about looks like (it is in [...]
Can I use a column in the WHERE clause that I created with ‘AS’ in the WHERE clause. I have tried and SQL tells me that the column is not in the table? Thanks, Ray
I am using SQL Server 2000, and my question is: is there any way to call a stored procedure in a SELECT list?
Hi, I am having a table which is having around 170 Columns(Don’t blame me but my Developer) and there are only 989 records in the table.I created all sorts of Indexes but still the query (Select * from Table) takes almost 2 mins to display 989 records.I need all the columns to be displayed.Is there [...]
GREYBEARD52: Thanks again for the info, BUT I’m not sure if a CL command can be used with a JCL. Can it? ALSO, my JCL uses the SELECT command, so it appears that the RUNSQLSTM command won’t help – it doesn’t support SELECT. Are there ANY OTHER ALTERNATIVES or a way to tweek this command [...]
Hi! When I try this: update fileD d set d.value = (select c.value from (select b.key, b.value from fileB b where b.key not in (select a.key from fileA a)) c where d.key = c.key) I get the message “Null values not allowed in column or variable VALUE.” on the other hand, when I do this [...]
Can we get the number of saturdays in any month using a SELECT statement(i.e without creating a table or function)? If so, can you give me the logic?
DATA SET: Table1 XID YID WRKDATE — — ——- 1 NOR 2007-01 2 SOU 2007-03 Table2 XID ZID QTY — — — 1 PEN 10 1 PAP 20 2 PAP 5 1 PEN 10 2 PAP 5 Result XID YID WRKDATE ZID QTY — — ——- — — 1 NOR 2007-01 PAP 20 1 NOR [...]
while executing the following qurie ‘inser into custmaster select * from tnjcust where seccode=’431′;’ answer is not enough valus
I am attempting to palce Nested Select Statements within a CLLE program and it will not accept the process. ie: SELECT wHEN a=B THEN(DO) PROCESS…. ENDDO WHEN C=D THEN(DO) PROCESS eNDDO WHEN (X=Y) tHEN(DO) select wHEN X1 = A tHEN(dO) PROCESS eNDDO wHEN X1 = b THEN(DO) PROCESS eNDDO eNDselect wHEN X=z tHEN(DO) ENDDO ENDSELECT [...]
I have a table with the main fields being BU, ASSET, BOOK for any BU and ASSET combination, there should be two to four rows of data, with just the BOOK value being different. Data corruption has caused us to find all BU-ASSET combinations missing the value ‘AMT’ for BOOK. I need to join the [...]





