Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8354123
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T09:27:38+00:00 2026-06-09T09:27:38+00:00

I have a stored procedure where I am using cross apply to get a

  • 0

I have a stored procedure where I am using cross apply to get a field “tagtext” from a table and then put each tagtext together as a entry in a new field called Tags in another table. I’m not to keen on how cross apply works though, and seem to be getting an error: Invalid Object myArticles.

The relevant code from my sp is:

BEGIN
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON;

    -- Insert statements for procedure here
    declare @RowStart int
    declare @RowEnd int
    IF (@Page=1)
        Begin

            set @RowStart=(@Page-1)*(@PageLen)
            set @RowEnd=(@RowStart+@PageLen);
        END
    ELSE
        BEGIN

            set @RowStart=((@Page-1)*(@PageLen))+1
            set @RowEnd=((@RowStart+@PageLen))-1
        END;
        With myArticles as 
(select ROW_NUMBER() over (ORDER BY publicationdate DESC) as 'RowNumber',*

From article_v
where articleID in(select articleID from savedarticle where userID= @UserID)  and
title like '%'+@keyword1+'%' and
title like '%'+@keyword2+'%' and
title like '%'+@keyword3+'%' and
title like '%'+@keyword4+'%' and
title like '%'+@keyword5+'%' 
)

(select mA.*,
isnull(left(Tags,len(Tags)-1),'') as Tags
from myArticles mA
  cross apply (select tagtext +', '
    from usertag uTag 
    where uTag.userID=@userID and uTag.usertagID in(select usertagID from articletag aTag where aTag.articleID=mA.articleID)
    for xml path('')) ca(Tags)
 )
        select 
            rownumber,journalID,journalname,articleID,title,publicationdate,medabbr, authors, Tags
            from  myArticles where RowNumber Between @RowStart  and @RowEnd
END


GO

Then, the web service I am using the sp in is:

<WebMethod()> _
Public Function GetSavedArticlesWithAbbr(ByVal mobileGUID As String, ByVal pageNum As Integer, ByVal pageLen As Integer, ByVal keywords As String) As List(Of ipadArticle)
    Dim result As New List(Of ipadArticle)
    keywords = HttpUtility.UrlDecode(keywords)
    Dim tempParamKW() As String = {"", "", "", "", ""}
    Dim tempKW() As String = keywords.Split(" ")
    Dim tempILoop As Integer = 0
    For Each s As String In tempKW
        tempParamKW(tempILoop) = s.Trim
        tempILoop += 1
    Next
    Dim simpuser As SimpleUser = utils.GetSimpleUserInfoFromMobileGUID(mobileGUID)
    If simpuser.isValid Then
        Dim lq As New lqDFDataContext
        Dim var = lq.mobile_GetSavedArticlesJW(simpuser.UserID, tempParamKW(0), tempParamKW(1), tempParamKW(2), tempParamKW(3), tempParamKW(4), pageNum, pageLen)
        For Each a_var In var
            Dim ipadartcicle As New ipadArticle()
            ipadartcicle.ArticleID = a_var.articleID
            ipadartcicle.PublishedOn = a_var.publicationdate
            ipadartcicle.Title = a_var.title
            ipadartcicle.MedAbbr = a_var.medabbr.Replace(" ", "-").ToLower()

            Dim tempTags() As String = a_var.Tags.Split(",")
            For Each t As String In tempTags
            ipadartcicle.Tags.Add(t)
            Next

            Dim tempAuthors() As String = a_var.Authors.Split(",")
            For Each a As String In tempAuthors
            ipadartcicle.Authors.Add(a)
            Next

            result.Add(ipadartcicle)
        Next     'this is where i get the error
    End If
    Return result
End Function
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T09:27:41+00:00Added an answer on June 9, 2026 at 9:27 am

    I’d say that you wanted to chain another cte between closing and opening parenthesis in following code but forgot about it:

    title like '%'+@keyword5+'%' 
    )
    
    (select mA.*,
    

    This should probably be

    title like '%'+@keyword5+'%' 
    ),
    myArticles2 as (select mA.*,
    

    And final part of query should then use myArticles2. As it is written now, last select is not a part of cte query.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a stored procedure that updates a table using linq, eg: (this is
I can get the code of a stored procedure using the syscomments table. select
I have a stored procedure that I'm using to populate a table with about
I have a problem when debugging stored procedure using SQL server Management Studio 2008.
I have a stored procedure in oracle which is using cursor.Its fetching the data
I have a stored procedure with multiple insert/select statements. Let's say I'm using the
Using MS SQL Server .I have made a Stored Procedure named SP_Get_CallsLogged . I
I am using Oracle 10g and I have the following stored procedure: CREATE OR
I have just created a report in Report Manager using a Stored Procedure which
I'm using devexpress and i have two problems. My insert stored procedure work fine.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.