Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. T-SQL Stored Pro Help [modified]

T-SQL Stored Pro Help [modified]

Scheduled Pinned Locked Moved Database
databasequestionhelpcareer
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    Hulicat
    wrote on last edited by
    #1

    I have the following stored procedure that works except that the "print" does display on the page when the "IF" condition is met...it shows up as a message when run from Query analyzer but not when the stored procedure is called. Can anyone tell me what is wrong with my print? I have tried a few things with no success just errors. the solutions I saw in books online did not work for me. here is the stored procedure: ( @ticketid as varchar(20) ) AS Declare @Technician as varchar (40) declare @count int set @count=(Select count(*) from job_ticket WHERE job_ticket.job_ticket_id =Cast (@ticketid as varchar (20)) and status_type_id like '[1-2]') if @count =0 print 'there are no open tickets' set @Technician=(SELECT email FROM dbo.tech INNER JOIN dbo.job_ticket ON tech.client_id = job_ticket.assigned_tech_id WHERE job_ticket.job_ticket_id =Cast (@ticketid as varchar (20))) SELECT job_ticket.job_ticket_id, job_ticket.question_text 'Report', 'Ticket Number', @Technician 'Technician Assigned',job_ticket.subject 'Issue Description', report_date 'Open Date' FROM job_ticket WHERE job_ticket.job_ticket_id =Cast (@ticketid as varchar (20)) and status_type_id like '[1-2]' -- modified at 20:56 Thursday 17th May, 2007

    Regards, Hulicat

    A 1 Reply Last reply
    0
    • H Hulicat

      I have the following stored procedure that works except that the "print" does display on the page when the "IF" condition is met...it shows up as a message when run from Query analyzer but not when the stored procedure is called. Can anyone tell me what is wrong with my print? I have tried a few things with no success just errors. the solutions I saw in books online did not work for me. here is the stored procedure: ( @ticketid as varchar(20) ) AS Declare @Technician as varchar (40) declare @count int set @count=(Select count(*) from job_ticket WHERE job_ticket.job_ticket_id =Cast (@ticketid as varchar (20)) and status_type_id like '[1-2]') if @count =0 print 'there are no open tickets' set @Technician=(SELECT email FROM dbo.tech INNER JOIN dbo.job_ticket ON tech.client_id = job_ticket.assigned_tech_id WHERE job_ticket.job_ticket_id =Cast (@ticketid as varchar (20))) SELECT job_ticket.job_ticket_id, job_ticket.question_text 'Report', 'Ticket Number', @Technician 'Technician Assigned',job_ticket.subject 'Issue Description', report_date 'Open Date' FROM job_ticket WHERE job_ticket.job_ticket_id =Cast (@ticketid as varchar (20)) and status_type_id like '[1-2]' -- modified at 20:56 Thursday 17th May, 2007

      Regards, Hulicat

      A Offline
      A Offline
      andyharman
      wrote on last edited by
      #2

      How are you running your stored procedure? Under ADO, a print statement does not create a resultset. Instead it adds an item to the Connection.Errors array. Normally I would do the zero-records check back on the front-end (because the resultset is empty). Also, most people add "SET NOCOUNT ON" to the top of their SQL-Server stored procedures.

      H 1 Reply Last reply
      0
      • A andyharman

        How are you running your stored procedure? Under ADO, a print statement does not create a resultset. Instead it adds an item to the Connection.Errors array. Normally I would do the zero-records check back on the front-end (because the resultset is empty). Also, most people add "SET NOCOUNT ON" to the top of their SQL-Server stored procedures.

        H Offline
        H Offline
        Hulicat
        wrote on last edited by
        #3

        Thanks for the tips, they are greatly appreciated.

        Regards, Hulicat

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups