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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T12:03:15+00:00 2026-05-16T12:03:15+00:00

This table valued function compiles ok, alter function [dbo].[ftsls031nnnHades](@withExpiredEntries smallint ) returns @t table(

  • 0

This table valued function compiles ok,

alter function [dbo].[ftsls031nnnHades](@withExpiredEntries smallint ) returns 
@t table( comno     varchar(3), 
        t$cuno      varchar(6),
        t$cpgs      varchar(6),
        t$dile      float,
        t$qanp      float,
        t$stdt      varchar(10),
        t$tdat      varchar(10),
        t$disc      float,
        t$damt      float,
        t$cdis      char(3),
        t$gnpr      float,
        t$refcntd   float,
        t$refcntu   float) as
------------------------------------------------------*/
/*-------------------------------------------------------
declare @withExpiredEntries bit; set @withExpiredEntries =0
declare @t table( comno     varchar(3), 
        t$cuno      varchar(6),
        t$cpgs      varchar(6),
        t$dile      float,
        t$qanp      float,
        t$stdt      varchar(10),
        t$tdat      varchar(10),
        t$disc      float,
        t$damt      float,
        t$cdis      char(3),
        t$gnpr      float,
        t$refcntd   float,
        t$refcntu   float)
------------------------------------------------------*/
Begin
set quoted_identifier off
if (@withExpiredEntries = 0) -- without expired entries
    Begin
        insert @t
        select * 
        from openQuery(Hades ,"select '010' comno, trim(t$cuno) t$cuno,trim(t$cpgs) t$cpgs,t$dile,t$qanp,to_char(t$stdt,'dd Mon yy') t$stdt,to_char(t$tdat,'dd Mon yy') t$tdat,to_char(t$disc,'999.99') t$disc,t$damt,t$cdis,t$gnpr,t$refcntd,t$refcntu from baan.ttdsls031010 where (to_char(t$Tdat,'yyyy-mm-dd') >= To_char(current_date,'yyyy-mm-dd')) and (to_char(t$stdt,'yyyy-mm-dd') <= To_char(current_date,'yyyy-mm-dd')) 
               union all       select '020' comno, trim(t$cuno) t$cuno,trim(t$cpgs) t$cpgs,t$dile,t$qanp,to_char(t$stdt,'dd Mon yy') t$stdt,to_char(t$tdat,'dd Mon yy') t$tdat,to_char(t$disc,'999.99') t$disc,t$damt,t$cdis,t$gnpr,t$refcntd,t$refcntu from baan.ttdsls031020 where (to_char(t$tdAt,'yyyy-mm-dd') >= To_char(current_date,'yyyy-mm-dd')) and (to_char(t$stdt,'yyyy-mm-dd') <= To_char(current_date,'yyyy-mm-dd'))")
    return  
End
    insert @t
    select * 
        from openQuery(Hades ,"select '010' comno, trim(t$cuno) t$cuno,trim(t$cpgs) t$cpgs,t$dile,t$qanp,to_char(t$stdt,'dd Mon yy') t$stdt,to_char(t$tdat,'dd Mon yy') t$tdat,to_char(t$disc,'999.99') t$disc,t$damt,t$cdis,t$gnpr,t$refcntd,t$refcntu from baan.ttdsls031010  
               union all       select '020' comno, trim(t$cuno) t$cuno,trim(t$cpgs) t$cpgs,t$dile,t$qanp,to_char(t$stdt,'dd Mon yy') t$stdt,to_char(t$tdat,'dd Mon yy') t$tdat,to_char(t$disc,'999.99') t$disc,t$damt,t$cdis,t$gnpr,t$refcntd,t$refcntu from baan.ttdsls031020   ")
    return
end

it throws this error when selected

Msg 102, Level 15, State 1, Line 1
Incorrect syntax near ‘select ‘010’ comno, trim(t$cuno) t$cuno,trim(t$cpgs) t$cpgs,t$dile,t$qanp,to_char(t$stdt,’dd Mon yy’) t$stdt,to_char(t$tdat,’dd ‘.

  • 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-16T12:03:15+00:00Added an answer on May 16, 2026 at 12:03 pm

    Change double quote to single quote and see what happens…

    ...
    ..Hades ,'select '010' comno...
    ...
    

    You’ll also have to double up the contained singles too.

    When SET QUOTED_IDENTIFIER is ON, ” delimits an object/column name etc. Not a string. This is the default setting too.

    The SET QUOTED_IDENTIFIER OFF has no meaning at runtime: it’s set at CREATE/ALTER time… this is why you get the error at runtime not CREATE time. CREATE <> compile by the way… it’s compiled to a plan at runtime.

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

Sidebar

Related Questions

Given a table-valued function such as dbo.Split() from T-SQL: Opposite to string concatenation -
I have a table valued function that does a complex query and returns a
I tried everything but I couldn't overcome this problem. I have a table-valued function.
I'm trying to create a function in package that returns a table. I hope
I've a pretty complex table valued function doing inner joins over various tables. I've
I have created a Table-Valued function to return a comma seperated list, but am
I'm using a CLR table-valued function to SELECT and return the results of a
Consider this table on SQL Server wordID aliasID value =========================== 0 0 'cat' 1
please consider this table: PK_Id Number Year Month Value ------------------------------------------------------------------------- 1 1 2000 5
Lets Say i have a table like this WEB_LIST_TABLE KEY Value ---------------------------------------- 134 google.com

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.