Sybase List Function With Sum With Server?

Mar 2, 2014

I have a subquery that retunrns multiple lines. To solve it, I have used the List function. The separation of List function is comma.

TblBill is in the main query with many other tables.
(Select List(tblBatch.batchnr) From tblBatch where tblBatch.tr_id = tblBill.kfr_trans_id ) As Batchnr

This subquery returns: B12, B13, B14, B43 and so on...

Now I want to use SUM from another field (quant) from table tblBatch in the subquery and then separate those with a line break instead of comma. Batch number may occur several times and I want to summarize these

I want the subquery return like this:

---Batchnr---
3 B12
4 B13
1 B14
1 B43

and so on..

How do I solve it the best way with SQL Server?

View 3 Replies


ADVERTISEMENT

SQL Server 2012 :: Column X Is Invalid In Select List Because It Is Not Contained In Aggregate Function

Apr 3, 2015

I have a specific variation on the standard 'Column Invalid' question: I have this query that works fine:

SELECT vd.Question ,
csq.Q# ,
csq.Q_Sort ,
csq.Q_SubSort ,
AVG(CAST(vd.Response AS FLOAT)) AS AvgC ,
vd.RType

[Code] ....

When I add this second average column like this:

SELECT vd.Question ,
csq.Q# ,
csq.Q_Sort ,
csq.Q_SubSort ,
AVG(CAST(vd.Response AS FLOAT)) AS AvgC ,

[Code] ....

I get the error: Column 'dbo.vwData.Response' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.

Clearly things are in the right place before the change, so I can only assume that the OVER clause is my problem. Is this just not possible?

View 1 Replies View Related

Sybase 15.xxx Version (linking Sybase To Sqlserver 2005)

May 18, 2008

hi,

i tried the document below pertaining to linking sybase 12.5 to sqlserver 2000 and sqlserver 2005

http://forums.microsoft.com/TechNet/ShowPost.aspx?PostID=311875&SiteID=17
http://www.sybase.com/content/1029118/1029118.doc

but when our company upgrade the sybase to 15.x i can't find the oledb configuration stated on the document.



so i can't linked the sybase 15.x now to sqlserver 2005. can somebody help me.!!!please...

where i can find the oledb configuration in sybase 15.xx..

tnx..

View 1 Replies View Related

List Function

Aug 8, 2000

Converting Sybase to SQL Server !

On the Sql Server's database I did :

-- test list function with cursor
alter proc proc_list(@key varchar(255), @retlistvalues varchar(8000) output)
as
declare @incrcurs2 cursor
declare @value varchar(255)
declare @listvalues varchar(8000)
set @incrcurs2 = cursor scroll dynamic
for
select t.title_Id from publishers p, titles t where p.pub_id = t.pub_idand p.pub_id = @key
order by t.pub_id
open @incrcurs2
fetch next from @incrcurs2 into @value
select @listvalues = convert(varchar(255),@value)
WHILE @@FETCH_STATUS = 0
begin
select @listvalues = @listvalues + ',' + convert(varchar(255),@value)
fetch next from @incrcurs2 into @value
end
CLOSE @incrcurs2
DEALLOCATE @incrcurs2
select @retlistvalues = @listvalues
go
declare @listvalues varchar(8000)
execute proc_list '1389',@listvalues output
print @listvalues

With Sybase, easily :
Select t.pub_id, list(t.title_Id) from publishers p, titles t where p.pub_id = t.pub_id
And I 've got all the titles in a comma-separated string by publisher !!!!

So, with SQL Server, I suppose that if I want the result by publisher, I must imbricate two cursors !!!

Perhaps I dream
Or can somebody see a better solution ????
Thanks

Axel Thimonier

View 1 Replies View Related

List Function

Nov 21, 1999

I've recently read in Joe Celko's "SQL For Smarties" book that there is a LIST() function in Sybase's SQL Anywhere that will aggregate string data into a single comma separated column.

Unfortunately, this command is not supported in T-SQL. Does anyone know how to achieve a similar result with conventional SQL, where I want to aggregate string data into a single column.

Here's my task. Say I have two tables, tParents and tChildren, a parent has many children. I want a sql statement that returns one row for each parent and the multiple children associated to each in a single comma separated column, i.e

Joe Blow 'Child1, Child2, ...'
Parent2 'Child4, Child5, ...'

The SQL with this LIST() function would look like:

Select Parent, List(tChildren.Child) as Children
From tParents, tChildren
Where tParents.PID = tChildren.CID
Group By Parent


Thanks in advance for any help.

Cheers,
Steve Roch
Research Systems, Inc.
stever@rsinc.com

View 2 Replies View Related

List Function

Sep 4, 2007

In sybase, there is function List, which joins few records in one cell. Is there any function, who does it in MS SQL?

View 14 Replies View Related

Using Parameter (@value) For IN Function List

Jul 20, 2005

I am trying to select a group of records based on a parameter valuepassed to the db from a web page. The value comes in as @Status andhas a list of statusID's: (1,2,5,9) I've tried to use"Where table.status IN (Select * from @Status AS ValueList)"And also tried"Where table.status IN (@Status)"And neither worked. Any suggestions?

View 2 Replies View Related

Function For Return Element List From A Query

Aug 9, 2007

Hello,

I have do a sql function for return a list of element from a query send in variable.



When I test the function on self I have no problem.

But when I use the function in a sql query I have problem.

example :




Code SnippetSELECT APPLI_SUPPLIER.N_SUPPLIER_ID, APPLI_SUPPLIER.V_SUPPLIER_LABEL,
dbo.APPLI_RETURN_LIST_ITEM('SELECT DISTINCT APPLI_CONSTRUCTION.V_PROCESS_CODE FROM APPLI_CONSTRUCTION INNER JOIN APPLI_SUPPLIER_SKILL ON APPLI_CONSTRUCTION.N_SUPPLIER_ID = APPLI_SUPPLIER_SKILL.N_SUPPLIER_ID WHERE (APPLI_CONSTRUCTION.V_PROCESS_CODE IS NOT NULL) AND (APPLI_SUPPLIER_SKILL.N_SKILL_ID IN (2,3,4,5,6))')
AS V_PROCESS_ITEMS
FROM APPLI_SUPPLIER INNER JOIN
APPLI_SUPPLIER_SKILL ON APPLI_SUPPLIER.N_SUPPLIER_ID = APPLI_SUPPLIER_SKILL.N_SUPPLIER_ID
WHERE (APPLI_SUPPLIER_SKILL.N_SKILL_ID IN (2, 3, 4, 5, 6))






This is the error :

Server: Msg 557, Level 16, State 2, Procedure APPLI_RETURN_LIST_ITEM, Line 24
Only functions and extended stored procedures can be executed from within a function.



When I do an exec of the function I have this problem :



Code Snippet
exec APPLI_RETURN_LIST_ITEM('SELECT DISTINCT APPLI_CONSTRUCTION.V_PROCESS_CODE FROM APPLI_CONSTRUCTION INNER JOIN APPLI_SUPPLIER_SKILL ON APPLI_CONSTRUCTION.N_SUPPLIER_ID = APPLI_SUPPLIER_SKILL.N_SUPPLIER_ID WHERE (APPLI_CONSTRUCTION.V_PROCESS_CODE IS NOT NULL) AND (APPLI_SUPPLIER_SKILL.N_SKILL_ID IN (2,3,4,5,6))')


Server: Msg 170, Level 15, State 1, Line 1
Line 1: Incorrect syntax near 'SELECT DISTINCT APPLI_CONSTRUCTION.V_PROCESS_CODE FROM APPLI_CONSTRUCTION INNER JOIN APPLI_SUPPLIER_SKILL ON APPLI_CONSTRUCTION.N_SUPPLIER_ID = APPLI_SUPPLIER_SKILL.N_SUPPLIER_ID WHERE (APPLI_CONSTRUCTION.V_PROCESS_CODE IS NOT NULL) AND (APPLI_SUPPLIER_SKILL.N_SKILL_ID IN (2,3,4,5,6))'



This is the function



Code Snippet
CREATE FUNCTION [dbo].[APPLI_RETURN_LIST_ITEM]
(@QUERY AS VARCHAR(3900)=null)
RETURNS varchar(8000)
AS
BEGIN
-- Insert statements for procedure here
declare @v_List_ITEM as varchar(8000)
set @v_List_ITEM=''
if @QUERY is not null
Begin
declare @cur_Lect_ITEM CURSOR;
declare @FUNCTION AS NVARCHAR(4000);
Declare @ITEM as VARCHAR(255);
SET @FUNCTION = 'set @mainCursor=cursor for ' + @QUERY + ' for read only open @mainCursor'


EXEC sp_executesql @FUNCTION,N'@mainCursor cursor output', @cur_Lect_ITEM output
fetch next from @cur_Lect_ITEM into @ITEM
while @@fetch_status=0
begin
set @v_List_ITEM=@ITEM + ' ; ' + @v_List_ITEM
fetch next from @cur_Lect_ITEM into @ITEM
end
deallocate @cur_Lect_ITEM
SET @v_List_ITEM=REPLACE(REPLACE(@v_List_ITEM, CHAR(13), ''), CHAR(10), '')
set @v_List_ITEM=left(@v_List_ITEM,len(@v_List_ITEM)-3)
End
RETURN @v_List_ITEM
END


Can you help me please?
Thank you

View 11 Replies View Related

T-SQL (SS2K8) :: Function To List Distinct Pax Name And Ticket Numbers?

Mar 14, 2014

I have data in a table Item_TB that I need to extract in a way that pulls out the distinct pax name and all the ticket numbers associated with the passenger per booking reference.

The data is:

Branch Folder ID Pax TktNo BookingRef
HQ 123 1 Jim 4444 ABCDE
HQ 123 2 Bob 5555 ABCDE
HQ 123 3 Jim 6666 ABCDE
HQ 123 4 Bob 7777 ABCDE
HQ 124 1 Jenny 8888 FGHIJ
HQ 124 2 Jenny 9999 FGHIJ
HQ 124 3 Jenny 3333 FGHIJ

I somehow need to get a function to pull the data out for each booking ref like so

--BookingRef ABCDE
Jim 4444/
6666
Bob 5555
7777
--BookingRef FGHIJ
Jenny 8888/
9999/
3333

I know I can get a simple function to return the all data, but I do not know how to only include the pax name once.

View 4 Replies View Related

Function To Create Comma Separated List From Any Given Column/table.

Jul 20, 2005

Hi,I'm sure this is a common problem.. to create a single field from awhole column, where each row would be separated by a comma.I can do this for a specified table, and column.. and I've created afunction using VBA to achieve a more dynamic (and very slow) solution..so I would like to implement it using a user defined function in sql server.The problems I'm facing are, that I can't use dynamic sql in afunction.. and I also can't use temporary tables which could build up a'standard' table from parameters given to then perform the function on.So, with these limitations, what other options do I have?Cheers,Chris

View 1 Replies View Related

SYBASE To SQL Server 7.0

Jun 19, 2001

Hi all,

A question that may have been asked on many occasions, but what can be advised as the best way to migrate a Sybase 11.x DB to SQL 7.0, (without using BCP). Does DTS support such migrations and if so, where in DTS can this be done? I'd appreciate any basic help here to get me started on this exercise. MAny thanks

View 2 Replies View Related

MS SQL Server Vs Sybase

Mar 18, 2003

Hello,

We have Trading Applications (Equities & Portfolio written on C++) on MS SQL Server 2000. Now the management is deciding to move it on Sybase 12.5. We currently don't have any issues on any matter, but because everyone is SYbase fan here, thinks applications are critical and we need to move to Sybase. Can anyone who has worked on both knows the major pros & cons of both the system. Actually I wanted these systems to be on MS SQL Server. I need solid reasons except being cheaper than Sybase to show why we should use MS SQL Server

If anyone can share their experiences, it would be really great.

Thanks
Sejal

View 2 Replies View Related

Sybase + SQL Server 2K

Mar 30, 2006

Hello!

Has anyone ever experienced compatibility and/or performance issues when SQL 2K and Sybase are run concurrently on the same server? I believe the server is using Windows 2K3.

Thanks!

View 5 Replies View Related

Connecting To Sybase From SQL Server

Dec 14, 2001

Hi,
I have a situation where in I need to insert a record in sybase database table whenever there is an update on a table in my sql server database.
Can any one suggesst me hoe can I do it?
thanks In advance
Mohan

View 2 Replies View Related

MS SQL 7.0 To Sybase Via Linked Server With OLE DB

Jul 5, 2001

We have created linked servers that connect to Sybase databases using the Sybase OLE DB provider and the Sybase ODBC provider.

The OLE DB provider does not allow the execution of a stored procedure. The message sounds like a permissions issue, but the id specified in the linked server has execute priv. for the stored procedure. It also does not allow the fully qualified name <server>.<db>.<owner>.<obj> to be used.

There are other issues with OLD DB and ODBC.

Anyone have any experiences making MS SQL to Sybase work smoothly?

View 3 Replies View Related

Replication : Sybase - SQL Server;

Mar 15, 2006

Hi all,

Have anyone done the replication between Sybase and MS SQL server ?

Could you please let me know the efficient way to 'PUSH' data from Sybase to MS SQL server or 'PULL' data into MS SQL server from Sybase.

Thanks,

Hari Haran Arulmozhi

View 2 Replies View Related

Linked Server To Sybase 15.5

Jun 1, 2015

Cannot create an instance of OLE DB provider "ASEOLEDB" for linked server "[SERVER_NAME]"

The current setup: Our primary database is on Sybase, I needed to extract hierarchical (nested) XML from multiple tables on Sybase. Although Sybase ASE 15.5 has `FOR XML` query capability it does now allow nested XML format. So we used the 'FOR XML', XML functionality in SQL Server (as we had a SQL Server 2008 database available which is used for a smaller system) to query Sybase tables through a Linked Server connection.Our sample nested XML Format is similar to:

<personCol>
<person>
<id>1111</id>
<name>John</name>
<age>21</age>
<sex>M</sex>

[code]....

View 2 Replies View Related

Replication Between Sql Server And Sybase

Jun 4, 2008

I need to configure snapshot replication (Pull) on Enterprise Edition of SQL Server 2005 (acting as Distributor, Subscriber) for Sybase server (acting as Publisher). I have the Sybase ASE client and ODBC driver installed on the Distributor. Can anyone help me add Sybase server as the publisher? Oracle publisher is allowed in Enterprise edition, but sales representative had said that we could have ODBC compliant server as the publisher. There is no option to select a different publisher other than SQL Server publisher, Oracle Publisher. If anyone knows how to do, please let me know.

View 8 Replies View Related

Instructions For Setting Up A Sybase ASE Server As A SQL Server 2005 Linked Server?

Dec 28, 2005

I have a Sybase Adaptive Server Enterprise server which I need to set up as a linked server in SQL Server 2005.  The Sybase server is version 12.5.2, and the Sybase ODBC driver version is 4.20.00.67.  I have already installed the Sybase client software on the server.


I also created a SystemDSN on the SQL Server to connect to the Sybase server.  I tested the connection and it was able to connect.

I ran the following code to create the linked server:

<code>

EXEC master.dbo.sp_addlinkedserver @server = N'LinkedServerName', @srvproduct=N'Sybase', @provider=N'MSDASQL', @datasrc=N'Sybase System DSN', @provstr=N'"Provider=Sybase.ASEOLEDBProvider;Server Name=servername,5000;Initial Catalog=databasename;User Id=username;Password=password"'

</code>

I then ran sp_tables_ex to make sure I could view the tables in the Sybase database.  Here is the error message I get:

<code>

OLE DB provider "MSDASQL" for linked server "LinkedServerName" returned message "[DataDirect][ODBC Sybase Wire Protocol driver]Error parsing connect string at offset 13. ".

Msg 7303, Level 16, State 1, Procedure sp_tables_ex, Line 41

Cannot initialize the data source object of OLE DB provider "MSDASQL" for linked server "LinkedServerName".

</code>

Any ideas what is happening here?

View 10 Replies View Related

Issue With Sql Server To Sybase Linked Server Using Stored Procedure

Sep 27, 2007

I have a linked server from Sql Server 2000 to Sybase Adaptive Server 12.5.1.

When i try to call a stored procedure on Sybase from Sqlserver i get the following message:

"could not execute procedure sp_who on remote server 'linked server name'(42000,7212)

command executed from sql server:
exec <linked_server>.<database>..sp_who


i am able to user open openquery for selects and inserts, successfully

Help appreciated

Thanks.

View 4 Replies View Related

SYBASE, I Know It Is Not SQL Server But This Is A Long Shot

Oct 1, 2001

To anyone who knows how to use sybase. One of our guys has put in a sybase system and not told the rest of us about it and know their is a problem and it is in my lap. Surprise, surprise.
Just asking does antyone know how to rebuild a sybase database after it has been recovered from previous data and is now twice the size that it was origonally. Please help if any one can>

Many thanks to any one who can help.

View 1 Replies View Related

Sybase Link Server(Urgent)

Jan 30, 2003

Hello,

I want read only connection to Sybase server from MS SQL Server 2000. I think Link server should be best solution. Can anyone guide me as help shows link of Oracle but not sybase. any help is apreciated.
I've written following on creating link server from ER
ProductName : Sybase ASE
Datasource : Server A
providerstring: DRIVER={Sybase.ASEOLEDBProvider};SERVER=unixbox,45 10;UID=sa;PWD=abc1411'

Thanks A Lot

View 4 Replies View Related

Connecting To Sybase From MS SQL Server 2000

Feb 24, 2003

I've installed Sybase client 12.0 and have created the DSN (it is successful, connection is established)
but when I run this ActiveX Script from DTS Package it give me error Data Source Name not found and no default driver specified

Dim RS
Dim oConn


Set oConn = CreateObject("ADODB.Connection")
msgbox "set oConn"
Set RS = CreateObject("ADODB.Recordset")
msgbox "RS"
(I've tried both open statement in both it gives me same error)
oConn.Open = "Driver={Sybase ASE ODBC Drivers};Srvr=Server1;Uid=sa;Pwd=password"

oConn.Open="DSN=Test;Uid=sa;Pwd=password"
msgbox "open"

Can anyone guide me?

Thanks in advance

-Sejal

View 2 Replies View Related

SQL Server 2000 & Sybase Replication

May 20, 2002

Hi all,

I'm trying to configure replication between a Sybase ASE Database Server and SQL Server 2000. Sybase ASE Database will be the Publisher and SQL Server will be the Subscriber. Can anyone advise me on how I can go about setting up the replication for this?

Thanks!

View 1 Replies View Related

Conversion From Sybase To SQL Server 2000

Oct 15, 2004

Hi,
Could anyone refer me any kind of tools or process to convert from SYBASE to SQL SERVER 2000.
My complany is trying to migrate from SYBASE to SQL SERVER 2000.
Any help is greately appreciated!
Thanks.

View 2 Replies View Related

Synchronize Sybase And SQL Server 2000

Nov 29, 2005

Hi All,

Could anyone please let me know which is the best way to Synchronise a Sybase database with a MS SQL Server 2000 database.That is , the changes made in the Sybase database should be reflected in the SQL Server database.

Thanks in advance !!

regards,

Hari Haran Arulmozhi

View 3 Replies View Related

Sync Sybase And SQL Server 2000;

Mar 15, 2006

Hi all,

I have a module in power builder with Sybase database as its backend. The other modules related to the same application are running on Delphi with SQL server as backend.

My requirement is to sync between the Sybase database and SQL server (2000) in order to update the SQL server with all the transactions ( online ) done in the Sybase database.

Thanks in advance ,

Hari Haran Arulmozhi

View 2 Replies View Related

Creating Linked Server To Sybase IQ

Nov 10, 2006

I would like to create a linked server from SQL Server to Sybase IQ. I have created linked servers before so I know how to do that. However, I dont know the specifics of creating a linked server to Sybase IQ.

What are the parameters that are necessary to link IQ to SQL Server. Which Provider do I use? Do I need to install a special driver?

View 2 Replies View Related

Migrating Sybase To SQL Server 2000

Feb 25, 2008

Hi all

I try to migrate sybase to SQL Server 2000, but found a los of trouble, please, some can help me to resolve this???

May many of that are easy to resolv, but is mi fist time with SQL Server 2000... plz, help :(

Object : Procedure
Error : Sintaxis incorrecta cerca de la palabra clave 'cursor'.
Code :

Create Procedure ABA_CenResul
as
Begin
declare @EST_CEN_Codigo char(8),
@EST_CEN_Descripcio char(100),
@n char(100),
@name char(100),
@salida char(8),
@vble int,
@ini int,
@ter int,
@indice int,
@aux_descripcion char(100)
declare sonido cursor
for
select EST_CEN_Codigo, EST_CEN_Descripcio
from EST_CenResul
open sonido
fetch sonido into @EST_CEN_Codigo,@EST_CEN_Descripcio
select @EST_CEN_Descripcio = @EST_CEN_Descripcio + " "
select @aux_descripcion = @EST_CEN_Descripcio
while @@sqlstatus !=2
begin
select @indice = 1
while @indice <> 4
begin
select @vble = patindex("% %",@EST_CEN_Descripcio)
select @ter = @vble - 1
select @name = substring(@EST_CEN_Descripcio,1,@ter)
if @indice = 1
select @n = @name
else
select @n = @n + "/" + @name

select @ini = @vble + 1
select @EST_CEN_Descripcio = substring(@EST_CEN_Descripcio,@ini,100)
select @indice = @indice + 1
end
print @n
exec sdxsrvr...soundex @n, @salida out
update EST_CenResul
set EST_CEN_Soundex = @salida
where EST_CEN_Codigo = @EST_CEN_Codigo
fetch sonido into @EST_CEN_Codigo, @EST_CEN_Descripcio
-- select @EST_CEN_Descripcio = @EST_CEN_Descripcio + " "
-- select @aux_descripcion = @EST_CEN_Descripcio
end
close sonido
deallocate cursor sonido
end



Thnx in advance

View 2 Replies View Related

Linked Server Connection To Sybase

Mar 11, 2004

Has anyone had problems using an OLEDB linked server connection to Sybase ASE 12.5? I'm having major performance problems when I use string criteria in the where clause. Queries that return 1 row and execute in less than a second using a native Sybase connection take 40 seconds to run using the linked server OLEDB connection. If I use ints in the where clause performance is almost exactly the same between native and linked connections.

Any ideas???

View 9 Replies View Related

Migration Sybase To Sql Server 2005

Jan 3, 2008

Hi all,
I am Migrating a database from sybase to sql server 2000. I Have already created objects in sql server 2000. I have to only populate it with the data. I have decided to genrate insert script from the aquadata tool and run the script againgt sql server database. It works fine except for few table which have 1,50,000 and 9,00,000 rows. It shows insufficent memory error when i try to run the script with 1,50,000 and the script with 9,00,000 doesn't open in management studio. Please help.


Bharath JrDBA

View 9 Replies View Related

Import Sybase Db To Sql Server 2000

Mar 3, 2008

How can import sybase db (sql any where) to sql server 2000 ?
sybase can be imported to sql server how ?

I try to import but there is no option to import sybase db
by tool -> data transformation services -> import / export data

Regards
Mateen

View 2 Replies View Related

Need Material For Sybase To Sql Server Migration

Dec 6, 2005

Greetings,Can someone recommend me some online redbooks or anylink regarding "Migration from Sybase to Sql Server"?Any feedback will be appreciatedTIA

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved