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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T22:18:10+00:00 2026-05-15T22:18:10+00:00

I have many tables in my database and I am collecting calculated values with

  • 0

I have many tables in my database and I am collecting calculated values with following code and would like to Insert those values into other table. I am Using SELECT INTO method but database tells me that “Incorrect syntax near the keyword INTO line …”. I believe that there is something I am missing but not sure where. Code looks fine. Here is my code. Any help would be appreciated.

SELECT (second.[cdate]=@enddate) AS 'Date', first.[machine_no] AS 'No', 
tbl_machines.[manufacturer] As 'Manufacturer',
tbl_machines.[type] As 'Machine Type',tbl_machines.[game_name] AS 'Game Name',
tbl_machines.[accounting_denomination] AS 'Denom', 
(second.[turnover])-(first.[turnover]) AS 'Turnover',
(second.[total win])-(first.[total win]) AS 'Total win',
(second.[games played])-(first.[games played]) AS 'Games Played',
(second.[Bill in])-(first.[Bill in]) AS 'Bill In', 
(second.[credit in])-(first.[credit in]) AS 'Credit IN', 
(second.[cancel credit])-(first.[cancel credit]) AS 'Cancel Credit',
tbl_rate.[euro] AS 'euro rate',
tbl_rate.[dollar] AS 'dollar rate' 
INTO  tbl_daily
FROM tbl.meter first,tbl.machines,tbl_rate  
INNER JOIN tbl_meter second ON first.[Machine_No] = second.[Machine_No] 
AND 
tbl_machines.[local_no]=first.[machine_no]
WHERE first.[cDate] = @StartDate 
AND second.[cDate] = @EndDate 
AND tbl_rate.[cdate]=@enddate;

Ok, I used INSERT INTO syntax, everything is going well but now I have problem with datetime. When I used following sql command I am getting error and it says ” Cannot convert data type bit to datetime” I tried Martin’s cast method but it’s same.

My code is

INSERT INTO tbl_daily SELECT tbl_machines.[ID] AS 'ID', (second.[cdate]=@enddate) AS 'CDate', first.[machine_no] AS 'No',
 tbl_machines.[manufacturer] As 'Manufacturer',
tbl_machines.[type] As 'MachineType',
tbl_machines.[game_name] AS 'GameName',
tbl_machines.[accounting_denomination] AS 'Denom', 
(second.[turnover]-first.[turnover]) AS 'Turnover',
(second.[total win]-first.[total win]) AS 'Totalwin',
 (second.[games played]-first.[games played]) AS 'GamesPlayed', 
(second.[credit in]-first.[credit in]) AS 'CreditIN',
 (second.[Bill in]-first.[Bill in]) AS 'BillIn', 
 (second.[cancel credit]-first.[cancel credit]) AS 'CancelCredit',
tbl_rate.[euro] AS 'eurorate',
tbl_rate.[dollar] AS 'dollarrate' 
 FROM tbl_meter first,tbl_machines,tbl_rate 
INNER JOIN tbl_meter second ON first.[Machine_No] = second.[Machine_No] AND tbl_machines.[local_no]=first.[machine_no] 
WHERE first.[cDate] = @StartDate AND second.[cDate] = @EndDate AND tbl_rate.[cdate]=@enddate;
  • 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-15T22:18:11+00:00Added an answer on May 15, 2026 at 10:18 pm

    NB: Below answer was written assuming SQL Server. I deleted it when receiving the VistaDB clarification but have undeleted it again upon reading that

    VistaDB can be thought of as a subset
    of Microsoft SQL Server T-SQL. All of
    our syntax is supported in SQL Server,
    but not the other way around

    In that case I assume it is safe to say that if it is invalid in SQL Server it will be invalid in VistaDB also? This is invalid syntax in SQL Server.

    SELECT (second.[cdate]=@enddate) AS 'Date'
    

    What is the purpose of this bit of code? Is it meant to be a boolean? (i.e. return true when the column matches the variable). If so in SQL Server the closest to that would be this.

    SELECT CAST((CASE WHEN second.[cdate]=@enddate THEN 1 ELSE 0 END) AS BIT) AS 'Date'
    

    Edit From the comments I see it is intended to be

    SELECT @enddate AS 'Date'
    

    Additionally I don’t see SELECT ... INTO listed as a VistaDB command here. Is it definitely supported?

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

Sidebar

Related Questions

I have the following tables in my database that have a many-to-many relationship, which
I have database with many tables. In the first table, I have a field
I have an access database with many tables. I am looking for a field
I have a very large Oracle database, with many many tables and millions of
I have many tables that use Lookup/Enum references for most of their column values.
Many applications have grids that display data from a database table one page at
I have a star schema type data base, with fact tables that have many
I have a table within my database that has many records, some records share
I have many tables with identical schemas but different names. Can I create a
I have many tables, say T1, T2, T3. Every table has a column named

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.