[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Where Is The Problem with link server query?

Posted on 2004-09-28
4
Medium Priority
?
765 Views
Last Modified: 2008-01-09
I have a table like:
In my server

CREATE TABLE dbo.[tbl_C09_SMSC_To_PSA] (
            [Entry_Date] [smalldatetime] NULL ,
            [Usage_Date] [smalldatetime] NULL ,
            [Process_Date] [smalldatetime] NULL ,
            [Source_System] [char] (4) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
            [Total_Event] [bigint] NULL
) ON [PRIMARY]

GO

And

CREATE TABLE [PSA20040919] (
            [ENTRY_DATE] [smalldatetime] NULL ,
            [FILE_NAME] [char] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
            [RECTYPE] [char] (5) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
            [A_NUMBER] [char] (15) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
            [B_NUMBER] [char] (30) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
            [PSA_DATE] [char] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
            [PSA_TIME] [char] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
            [TARIFF_PLAN] [char] (5) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
            [CURRENCY_SIGN] [char] (5) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
            [CHARGED_AMOUNT] [float] NULL ,
            [REMAINING_BALANCE] [float] NULL ,
            [OPERATION] [char] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
            [DATE_USAGE] [smalldatetime] NULL
) ON [PRIMARY]

 

in the server gpra740
now I would like to do following Query on my server :

insert into dbo.tbl_C09_SMSC_To_PSA

(entry_date,usage_date,process_date,source_system,total_event)
select '2004-09-01' as a ,date_usage,'20040901' as b ,'PSA' as c,count(*)  as d
from gpra740.psadb.dbo. PSA20040919 where charged_amount=-2.3
group by date_usage

 
But it generates Following Error:

Server: Msg 7341, Level 16, State 2, Line 1
Could not get the current row value of column '(user generated expression).Expr1003' from the OLE DB provider 'SQLOLEDB'. Could not convert the data value due to reasons other than sign mismatch or overflow.

[OLE/DB provider returned message: Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done.]

OLE DB error trace [OLE/DB Provider 'SQLOLEDB' IRowset::GetData returned 0x80040e21:  Data status returned from the provider: [COLUMN_NAME=Expr1003 STATUS=DBSTATUS_E_CANTCONVERTVALUE]].

 

 But if the PSA20040919 table is in my server

Like
    insert into dbo.tbl_C09_SMSC_To_PSA
(entry_date,usage_date,process_date,source_system,total_event)
select '2004-09-01' as a ,date_usage,'20040901' as b ,'PSA' as c,count(*)  as d
from dbo. PSA20040919 where charged_amount=-2.3
group by date_usage

  then runs smoothly, then what the problem with my previous query?

 Then another interesting things ! if I create a dummy  function then it also runs  
Like:

CREATE FUNCTION DBo.Fx_dummy (@mstring varchar(50))
RETURNs varchar(50)
--AS
BEGIN
     RETURN @mstring
END

 
insert into dbo.tbl_C09_SMSC_To_PSA
(entry_date,usage_date,process_date,source_system,total_event)
select dbo.Fx_dummy('20040901') as a ,date_usage,dbo.Fx_dummy('20040901')  as b ,dbo.Fx_dummy('PSA')as c,count(*)  as d
from gpra740.psadb.dbo.psa20040831 where charged_amount=-2.3
group by date_usage

Then What is the problem…..?
Can you help me on that ……

Thanks in advance

Muntasir

0
Comment
Question by:muntasirrahman
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 12

Accepted Solution

by:
kselvia earned 80 total points
ID: 12172900
I don't know why the remote server is mesing up the datatypes for SQL to be able to implicitly convert your dates but a solution without the functions might be;

insert into dbo.tbl_C09_SMSC_To_PSA
(entry_date,usage_date,process_date,source_system,total_event)
select '2004-09-01' as a ,date_usage,'20040901' as b ,'PSA' as c, d
from
(
select date_usage, count(*)  as d
from gpra740.psadb.dbo. PSA20040919 where charged_amount=-2.3
group by date_usage
) x


0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
This month, Experts Exchange sat down with resident SQL expert, Jim Horn, for an in-depth look into the makings of a successful career in SQL.
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Viewers will learn how the fundamental information of how to create a table.

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question