none
Creating a view of an sql query RRS feed

  • Question

  • when saving a existing viwew in Microsoft Viual Studio 10 the following error is given : Must declare the scalar variabl "@StartDate"

    Tried decalere and dim statements but none seem to work within the view creation. Initially I tried to pass paremeters straight from teh SQL command line but picked up a post that this is not possible and went the view route. Now my query works with teh option of preseneted start and end date values but it wont save

     

    below is the code within the view 

     

    SELECT        EVENT_ID, GROUP_NAME, FIRST_RESOLVE_DATE, FIRST_RES_TIME_7_TO_17_HRS, REPORT_PERIOD, REQUEST_AREA_NAME,
                             EVENT_TYPE_DESC, PRIORITY_CODE
    FROM            dbo.ht_v4a
    WHERE        (REPORT_PERIOD >= @StartDate) AND (REPORT_PERIOD < @EndDate) AND (REQUEST_AREA_NAME LIKE '%CBS%') AND
                             (REQUEST_AREA_NAME NOT LIKE '%TM%') AND (REQUEST_AREA_NAME NOT LIKE '%CNO%') AND (REQUEST_AREA_NAME NOT LIKE '%CBS_EXTRA%') AND
                             (EVENT_TYPE_DESC = 'Request')
    ORDER BY FIRST_RESOLVE_DATE

    Anybody got any ideas

    Tuesday, August 23, 2011 11:36 AM

Answers

  • Hi,

    Views cannot take parameters, so you will need to create a function or a stored procedure.

    Best regards,

    JA Reyes.


    Please remember to Vote & "Mark As Answer" if this post is helpful to you.
    Por favor, recuerda Votar y "Marcar como respuesta" si la solución de esta pregunta te ha sido útil.
    Tuesday, August 23, 2011 11:54 AM
  • Hi Stan,

    Welcome!

    I think you can refer LINQ to SQL Stored Procedure, If there is any updates of your question, please feel free to let us know your feedback.

    Have a nice day.


    Alan Chen[MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Friday, August 26, 2011 7:40 AM
    Moderator

All replies

  • Hi,

    Views cannot take parameters, so you will need to create a function or a stored procedure.

    Best regards,

    JA Reyes.


    Please remember to Vote & "Mark As Answer" if this post is helpful to you.
    Por favor, recuerda Votar y "Marcar como respuesta" si la solución de esta pregunta te ha sido útil.
    Tuesday, August 23, 2011 11:54 AM
  • Hi Stan,

    Welcome!

    I think you can refer LINQ to SQL Stored Procedure, If there is any updates of your question, please feel free to let us know your feedback.

    Have a nice day.


    Alan Chen[MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Friday, August 26, 2011 7:40 AM
    Moderator
  • Hi,

    I am writing to check the status of the issue on your side. Would you mind letting us know the result of the suggestions?

    If you need further assistance, please feel free to let me know. I will be more than happy to be of assistance.

    Have a nice day.


    Alan Chen[MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, August 30, 2011 7:31 AM
    Moderator