That makes sense. Thank you! I was beginning to thank that I was going to have to do a loop thru the data to make it work.
I'm not used to making multiple joins and that was exactly what I needed that you pointed out.
Thank you so much george!!
Been working on this for a couple of days, and I switched things around. Now I have it work (I think), but it's in the reverse, it displays only the viewed messages.
SELECT Messages_Admin.Subject, Messages_Admin.Message, Messages_Admin.CreatedDate, Messages_Admin.Createdby...
PS: there is also a org_ID field in table 1 which is only for segregating organizations but doesnt effect my output I just didnt include it in the example (incase you look at the code in my first question).
Table 1
Subject nvarchar(50)
Message nvarchar(Max)
CreatedBy nvarchar(50)
CreatedDate datetime
Msg_ID int (identity)
Table 2
User nvachar(50)
Msg_ID int
Viewed bit
VDate datetime
Table 1 Data
Subject: Hello World
Message: What a great snowy day in Dallas
Createby: Dalec
CreatedDate...
Ok, I think I've made myself nutty.
I just can't get the results I want and my mind has officially turned to clay.
What I have is a table that has a simple text field to store messages then I have a second table with user names that have viewed the message. The first table has a msgID and once...
...nvarchar,
@Org_ID int,
@Count int output
AS
BEGIN
-- Insert statements for procedure here
SET NOCOUNT ON;
SELECT @Count = COUNT(*)
FROM Messages_Admin LEFT OUTER JOIN
Messages_Viewed ON Messages_Admin.MsgID = Messages_Viewed.Msg_ID
WHERE (Messages_Admin.Org_ID =...
...that, don't know how I did that? Now I get a incorrect syntax near '>'
Current Code:
PROCEDURE Main_InvSch
@NameSch nvarchar(70)
as
SELECT * from Main_inventory
inner join (
select category
from Main_Inventory
where [descrip] = charindex(@NameSch, [descrip]) > 0...
Here is what I ended up with:
PROCEDURE Main_InvSch
@NameSch nvarchar(70)
as
SELECT * from Main_inventory
inner join {
select category
from Main_Inventory
where header = 1 and
description = charindex(@NameSch, [descrip]) > 0
} as CategoryQuery
on...
Thank you, I'll play around with this in the SP. I've always used standard query's and was really hoping for SQL to do the work on this one. This really helps. Thank you for the great explanation too.
Dale
thank you Ryan
Could you explain this a little. I'm getting most of it, looking in the entire table, sub query on header = 0 and with a search on category where the category = the category of a temp table?
Sorry if I'm missing something, I've just not done query's like this.
thanks in advance.
Yes, The data structure is like this:
Description nvchar 50
Qty
Cost
Category int
ID Identity
Header Bit
When an item is entered it can also be a Category Header (this is probably where my biggest hurdle is, since I used the same data base to store both header and...
...the categories searched . Can I use a sub-query to do that?
Here's my search query:
PROCEDURE Main_InvSch
@NameSch nvarchar(70)
as
SELECT * from Main_inventory
where charindex(@NameSch, [descrip]) > 0 and header = 1
order by [descrip]
Essentially I want the items and headers...
After about three weeks with this, I just want to say to anyone out there, make sure if you change your code (vb.net 2008) make sure you refresh any stored procedures your referencing from the datasets and tableadapters to stored procedures your using, because this was a nightmare, I just needed...
OK, now I don't believe it. I went to the data desinger and tested the stored procedure from there, it worked like it was suppose to. Now when I run the application, it's working. No real code or sp changes, just started working after I tested it there (maybe that needed a refresh)????
thanks...
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.