Hi!
This might be a bit faster then using a subquery:
SELECT
docnumber,
version
FROM
Documnets
LEFT OUTER JOIN
(SELECT
docnumber
FROM
Documents
WHERE
Version = 1) AS Version_1
ON Documents.docnumber = Version_1.docnumber
WHERE
Version_1.docnumber IS NULL
OR...
Hi!
The Code in the answer would return OK For the following string:
'a123.234' because 123.234 is numeric. I would suggest the following sollution:
CREATE FUNCTION dbo.CheckForOrderID (@vc1 VARCHAR(50))
RETURNS varchar(50) AS
BEGIN
DECLARE @okStatus varchar (50)
DECLARE...
Hi!
You can't do that. Instead of that you can create a temp table, insert the result in this one (INSERT INTO #table_name EXEC your_stored_procedure) and than work with this (I'm not sure but I think, that you can't use a table varieble in this place instead of the temp table). However you...
Hi!
Change the to inner joins to LEFT OUTER JOINs (I assume, that there is no row in tbl_Production for Employees who have not worked and, there is no rows in trainingtable for Employees who have not been trained).
Iker
Would this give the desired result?
SELECT
st.Item_Id,
st.Item_Name,
st.Quantity,
st.Sale_Price,
st.Quantity * st.Sale_Price as Value,
cast(sd.Department_Name as varchar(5)) + ' %' as Comission,
st.Quantity * st.Sale_Price * (cast(sd.Department_Name as int)) / 100 as...
Could you give a short explanation what your selct is trying to do? dos si has only one row?
Why are your tables not joined in any way?
Your where clause could also be stated putting this into the from part of the sellect:
Store_Dept sd
INNER JOIN Store_Items si
ON...
Hi!
I'm sorry, but I don't know the exact version of AS400 we are running. The thing is, that the IT department plans to buy a new server because we can't use the existing one (which has more then one processors), at least that's what they say). Because we can only use one processor (??????) we...
If you have a problem with the script running faste in query analyser than in your application, have a look at disconnected recordsets. ADO can get very slow if your recordset is connected.
IKER
AS/400 questions
At our company we are using AS/400 Servers for keeping record of our customer data. In the last period we had many problems, and I couldn't get clear answer from the IT department why. I am not realy experienced with big systems (I am more comfortable with Windows based systems...
Try using a trigger, but be careful, updateting the table wich caused the trigger to run can cause the trigger to run again. Look at what recursive triggers are and how to avoig refiring the trigger.
In the trigger you will have an Inserted object which contains al the inserted a modified...
Do you have a minimal and maximal size for numbers?
Ho big is your table (not very big).
Are they only int-s in your table?
If so, I now a not very dificult but easy way:
You create a table with one column containing numbers form max value to min value (for example 1 ... 100) - Numbers
Lets...
Try these selects. I found that an inner join is alway a better solution then everything else (especialy if you have some indexes defined on the given columns)
SELECT
jobid
FROM
INVSwitchTransvalidtbl
INNER JOIN (SELECT DISTINCT JobID FROM INVJobsTbl
WHERE periodid = 23) AS...
Hi!
What type of program do you need the passwords for (what kind of languege)? Maybe you should consider to build the encryption into your client, and save the password encrypted. If the user enters his password at the client, you only have to encrypt it and compare it with the saved value...
Hi!
You have a big problem: there is nothing like crosstab query in MS-SQL. If you want to make something like this, you will have to build it dynamicaly (except you have a given number of column headers). This is not very easy, you have to build a Cursor on a select returning the different...
SELECT
stquem.product,
AVG(stquem.unit_cost)
FROM
stquem
INNER JOIN
(SELECT
product,
MAX(date_received) AS date_received,
FROM
stquem
GROUP BY
product) AS Max_date_table
ON Max_date_table.product = stquem.product
AND Max_date_table.date_received =...
A permanent table is a bad idea if you have many users (many-many at the same time) and many records. However the above given example can handle some users (with some thousend of records/report) with ONE permanent table without any problem, and you don't have to mess around with ASP.
IKER
Look for the t-sql refference of IN and LIKE in SQL-help or on the internet:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnanchor/html/sqlserver2000.asp
IKER
Hi!
I think the following, more complicated code would be more efficient.
SELECT
Table_1.User,
Time,
....
FROM
Table_1
INNER JOIN
(SELECT
User,
MAX(Time) AS Time
FROM
Table_1
GROUP BY
PRODUCT) AS Max_time_table
ON Max_time_table.User = Table_1.User
AND...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.