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 8382103
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T16:51:23+00:00 2026-06-09T16:51:23+00:00

I have a stored procedure which retrieves multiple rows of 3 column items. I

  • 0

I have a stored procedure which retrieves multiple rows of 3 column items. I am retrieving in the format of DataTable. When I debug it it gives me error

Must Declare Scalar variable @Ticket.

But I have already declared that.

Stored procedure :

BEGIN

Declare @Ticket Numeric(28,0)
Declare @SQL VarChar(Max)
Declare @SQLUpdate VarChar(Max)

 Set @SQL='Select @Ticket=Ticket,VendorTicket[Vendor Ticket],Comments From dbo.VendorTickets Where NotifyOn <= GetDate() And IsNull(NotifyOn,0)<>0 '
 Exec(@SQL)

 Set @SQLUpdate='Update dbo.VendorTicket Set NotifyOn=0 Where Ticket=@Ticket'
 Exec(@SQLUpdate)

END

Code which calls stored procedure

SqlConnection oConn = null;
DataTable dtReturn = null;
try
{
getConnection(ref oConn, 1);
using (SqlStoredProcedure sspObj = new SqlStoredProcedure("dbo.usp_checkNotification", oConn, CommandType.StoredProcedure))
{
dtReturn = sspObj.ExecuteDataTable();
sspObj.Dispose();
}
closeConnection(ref oConn);
}
  • 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-09T16:51:24+00:00Added an answer on June 9, 2026 at 4:51 pm

    Why are you using dynamic SQL?

    Just do this

     Update dbo.VendorTickets
     Set NotifyOn=0 
     Where NotifyOn <= GetDate() 
     And NotifyOn IS NOT NULL
    

    Note that setting a datetime (NotifyOn) to 0 will set it to 1900-01-01.

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

Sidebar

Related Questions

I have written a stored procedure which retrieves more than 7000 rows. While executing
I have a report viewer which retrieves data from stored procedure to display. The
So I have a stored procedure in a SQLServer 2005 database, which retrieves data
I have a stored procedure which update a table based on such calculation and
I have a stored procedure which returns sys_refcursor and I am trying to fetch
I have a stored procedure which accepts a User defined table type called SeasonTable
I have a stored procedure which takes an XML parameter and inserts the data
I have a stored procedure which returns a ref cursor as follows: CREATE OR
I have a stored procedure which basically does something like select top 1 expiryDate,
I have a stored procedure which is doing a lot of delete. Hundreds of

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.