August 13, 2007 at 1:58 am
Hi,
I have a report which searches ok a user input but the same input is used on another report, the thing is they both need differant info. one needs the info in the format A10-06 but the other one only needs A10- so i was wondering if there was a way i could split the input (maybe on the '-')
thanks for any help.
EDIT: ok ignore this post. i had a stupid moment. i have figured it out, just limited the size of the variable. silly me.
August 13, 2007 at 2:52 am
OK, so iam not starting another post i thought i would ask this here.
the following code returns studentID and some other fields
-------------------------
DECLARE @sql varchar(1000) DECLARE @stat varchar(10) DECLARE @date varchar(20) DECLARE @tg varchar(4) DECLARE @sref varchar (15)
SET @tg = 'A10-06'
SET @stat = 'Poor'
SET @date = 'March2007'
SET @sql = 'SELECT a.* FROM OPENQUERY(SERVER4,''SELECT studentID,TG,student FROM Reports
WHERE (((`classwork` = "' + @stat + '" or `homework` = "'
+ @stat + '" or `midterm` = "' + @stat + '" ) AND `session` = "' + @date + '") AND `TG` ="' + @tg + '")
GROUP BY studentID
HAVING count(*)>=3
ORDER BY TG ASC'')AS a;'
EXEC (@sql)
------------------------
Does anyone know how i would be able to use the values returned for studentID in another query so i could get the name linked to it.
i.e. select name from *** where sturef = studentID
thanks again.
August 13, 2007 at 1:36 pm
Question was asked and answered after you posted, in a different thread:
http://www.sqlservercentral.com/forums/shwmessage.aspx?forumid=150&messageid=389554
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply