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

  • Home
  • SEARCH
  • 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 6593751
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:43:20+00:00 2026-05-25T17:43:20+00:00

I extracted the following snippet from Profiler (from a statement that fails due to

  • 0

I extracted the following snippet from Profiler (from a statement that fails due to “syntax error near ,”):

exec sp_executesql @statement = N'CREATE TABLE --other stuff...

  DECLARE @student_id_ticket INT
  EXEC @student_id_ticket = systecsys_get_next_ticket (select top 1 table_id from systecsys_table where name like ''%Student_List%''), ''n'', 1

--INSERT statement using this value and other stuff

I know that it fails because of the subquery, because when I use a hardcoded value, it works. Therefore, it could be that there is a problem of asynchronous processing or a general syntax error. T-SQL 2000.

Please suggest a remedy. Thanks!

  • 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-05-25T17:43:20+00:00Added an answer on May 25, 2026 at 5:43 pm

    Yeah, I don’t think you can use a subquery as a parameter to a stored procedure. The spec for the EXEC command states that value should be a object name, character string.

    Either use another variable to store the results, or change the stored procedure into a function.

    DECLARE @student_id_ticket INT, @table_id INT
    SELECT @table_id = (select top 1 table_id from systecsys_table where name like ''%Student_List%'')
    EXEC @student_id_ticket = systecsys_get_next_ticket @table_id, ''n'', 1
    

    or if systecsys_get_next_ticket is a function:

    DECLARE @student_id_ticket INT
    SELECT @student_id_ticket = systecsys_get_next_ticket((select top 1 table_id from systecsys_table where name like ''%Student_List%''), ''n'', 1)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have extracted the following code from selenium IDE.(c# remote control) using System; using
I want to develop an application that would extract the following things from an
following snippet is from rails code def rescue_from(*klasses, &block) options = klasses.extract_options! unless options.has_key?(:with)
I've extracted the following from a project we are working on: http://www.bridgedev1.com/videotest.html This plays
I have the following being extracted from an XML and being put into a
I have this following snippet in my ANT-buildfile, which reads filenames from a file
I have the following code snippet, which loads data from a CSV file into
The following code fragment does nothing, but illustrates the problem. It was extracted from
I have the following code snippet from a HTML file: <div id=rwImages_hidden style=display:none;> <img
Consider the following code snippet that takes user input (a date) and format it

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.