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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T14:29:42+00:00 2026-06-11T14:29:42+00:00

I want to create a view for this sql statement which previously works fine.

  • 0

I want to create a view for this sql statement which previously works fine. But when I create this into a view, A error prompting out showing that, "View's SELECT contains a variable or parameter." Can anyone tell me where the error falls as I am quite new to views in MySQL. Thanks!

CREATE VIEW `satsschema`.`viewTimeBreak` AS 
SELECT a.EmpName, CONCAT(b.StartTime, '-', b.EndTime) AS ShiftTime, CONCAT(a.EmpTime,     '-', ADDTIME(a.EmpTime, '0 1:0:0.000000')) AS BreakTime, a.Break, 
                     a.EmployeeOnBreak, '' AS SignIn, '' AS SignOut
FROM            satsschema.employeeslot a INNER JOIN
                     satsschema.ufis b ON b.UFISID = a.UFISEmpGroup
WHERE        (a.AllocationDate = @AllocationDate) AND (a.LocationName = @LocationName)   AND (a.Break = 1)
GROUP BY a.EmpName

This part shows the error when I tried to create a view using the sql statement.

  • 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-11T14:29:43+00:00Added an answer on June 11, 2026 at 2:29 pm

    You cannot have variables like @AllocationDate and @LocationName used in the query definition of a view itself.

    Instead what you can do is

    CREATE VIEW `satsschema`.`viewTimeBreak` AS 
    SELECT 
        a.EmpName, 
        CONCAT(b.StartTime, '-', b.EndTime) AS ShiftTime, CONCAT(a.EmpTime,     '-', ADDTIME(a.EmpTime, '0 1:0:0.000000')) AS BreakTime, 
        a.Break, 
        a.EmployeeOnBreak, '' AS SignIn, 
        '' AS SignOut,
        a.AllocationDate,
        a.LocationName 
    FROM            
        satsschema.employeeslot a 
        INNER JOIN satsschema.ufis b 
                ON b.UFISID = a.UFISEmpGroup
    

    And then put the conditions at the time of using the view

    so your SELECT statement would be

    SELECT * FROM `satsschema`.`viewTimeBreak` a 
    WHERE 
    (a.AllocationDate = @AllocationDate) 
    AND (a.LocationName = @LocationName)   
    AND (a.Break = 1)
    GROUP BY a.EmpName
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to create indexed view MyView with such t-sql Select o.Theme_ID as Theme_ID,
I want to create indexed view with such t-sql: Select Table1_ID, cast(CONVERT(varchar(8), t2.Object_CreationDate, 112)AS
hi i am using SQL Server 2008, want to create a view to list
I want to create view with 52 square or button (for 52 week in
I want to create a view that contains two forms with their submit buttons.
I want to create a view from the following two tables: Entry: entry_id entry_date
I want to create a view in a one-to-many relation. Here are my relations:
I'm using SharePoint 2010. I want to create new view for my list. The
I want to create a custom alert view within my iOS application. For example,
So I want to create a re-usable view for editing an Address, phone number,

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.