How Can I Simulate Group_concat In SQL CE?

Apr 24, 2008

I am referring to the group concatenation where we get all the values of a single column (of all the rows) grouped into one cell as a concatenated string. I know I can achieve this using temporary tables and cursors in SQL Server. But I cannot have a cursor in SQL CE. I need to add this as a command to a tableadapter in a Dataset Designer. Please let me know if you can think of a workaround.

This is what I want:
Table 1:

Col1 Col2
1 a
1 b
2 c
2 d
2 e

Resultset should be:

Table 2:

Col1 Col2
1 a, b
2 c, d, e

View 1 Replies


ADVERTISEMENT

Group_concat?

Jun 5, 2005

Is there anyway to concatenate the columns of a select statement over multiple rows

eg, say my select comes back with (its a big select with many joins etc)
FirstName LastName Other
Billy Bob Test1
Billy Bob Test2
Billy Bob Test3
Jon Smith fubar1
Jon Smith fubar2

I want it to return
Billy Bob Test1 Test2 Test3
Jon Smith fubar1 fubar2

I think the GROUP_CONCAT in mySQL performs this function, is there anything in ms sql

Thanks

Robbo

View 4 Replies View Related

Simulate 1,000 Simultaneous Users

Mar 29, 2000

How can I simulate 1,000 simultaneous users in my database?

View 3 Replies View Related

Simulate ROW_NUMBER () In SQL 2000

Nov 22, 2005

I would like to generate an incrementing column value to each row found in a query in SQL Server 2000. 

View 13 Replies View Related

Simulate A Row Change In The Replication Table

Dec 17, 2007

I have a merge where the subscriber can do changes to its tables ... But as I found out the changes are made only if publisher simulate an row change or changes something effectively
I'm not sure that at every replication the publisher table would be changed so i need something to simulate a change in the publisher table
Can anyone please help me with this ?

View 2 Replies View Related

How To Simulate Stored Procedure Execution

Jul 27, 2015

I want to simulate 100 users simultaneously  executing a procedure in sql server (best example would be 100 users using  one report with different parameters in ssrs at the same time ). can i do that ?

View 3 Replies View Related

Transact SQL :: Queries To Simulate INTERSECT And EXCEPT But With Records In Same Table

Jun 5, 2015

I have a table (let's call it MyTable) that consists of four fields:

Id, Source, FirstField, and
SecondField, where Source only takes one of two values:
Source1 and Source2.
The records in this table look as follows:

Id
Source
FirstField
Secondfield

1
Source1
Product 3 name
Product 3 description

[code]...

I need to return, using 3 different T-SQL queries:

1) Products that exist only in Source2 (in red above)
2) Products that exist only in Source1 (in green above)
3) Products that exist both in Source1 and Source2 (in black above)

For 1) so far I've been doing something along the lines of SELECT * FROM MyTable WHERE Source=Source1 AND FirstField NOT IN (SELECT DISTINCT (FirstField) FROM MyTable WHERE Source=Source2)

I have read about INTERSECT and EXCEPT, but I am a little unclear if they could be applied in this case out of the box.

View 7 Replies View Related

Analysis :: DAX - How To Simulate MDX SCOPE Forcing YEAR Level

Jul 19, 2015

In my fact table (month granularity), I've got a calculation defined: 

Margin%=DIVIDE(SUM(Margin);SUM(SalesAmount))

How should I define a calculation based on "Margin%", so that if I browse the Pivot Table by months it would always show the year level result instead? My date dimension is also with Month granularity and it has a Year column in it. 

View 2 Replies View Related

SQL Server 2008 :: Queries To Simulate INTERSECT And EXCEPT But With Records In Same Table

Jun 4, 2015

Here's the scenario. I have a table (let's call it MyTable) that consists of four fields: Id, Source, FirstField, and SecondField, where Source only takes one of two values: Source1 and Source2.

The records in this table look as follows:

I need to return, using 3 different T-SQL queries:

1) Products that exist only in Source2 (in red above)

2) Products that exist only in Source1 (in green above)

3) Products that exist both in Source1 and Source2 (in black above)

For 1) so far I've been doing something along the lines of

SELECT * FROM MyTable WHERE Source=Source1 AND FirstField NOT IN (SELECT DISTINCT(FirstField) FROM MyTable WHERE Source=Source2)

Not being a T-SQL expert myself, I'm wondering if this is the right or more efficient way to go. I have read about INTERSECT and EXCEPT, but I am a little unclear if they could be applied in this case out of the box.

View 5 Replies View Related

Simulate Heart Beat Code To Manage Production Servers

Jan 1, 2008



Hi

I am currently developing a DBA management console for a company who have 45 SQL Servers, 20 of which are in the production environment. As part of the development I have created a DBA dashboard with various alerts and information dials regarding the state of the SQL Infrastructure. I came accross a problem yesterday that I cannot find the answer to.

One of the alerts I have developed is a simple "Heart Beat" indicator that displays that the SQL Server is present and "alive". To do this I have a central database running on SQL 2005 which has linked server connections toall 45 SQL Servers. This central database runs a simple select statement on each server (something that I know works if the server is there). The select is run as dynamic SQL as I need to build up the SQL as part of a cursor to place the server name within the from clause. Here is the select I am using: -

select top 1 dbid from [server].master.dbo.sysdatabases

If the server is not there an error occurrs. I trap this and record that the server may not be present. The cursor then moves on to the next server to check.

This works fine when ran from Query Analyser. I can simulate a failed server by deleting the link server connection. For the server in questions an error is raised when the select is run, I store the error and on the Dashboard screen you can see an indicator saying that the server is currently non-contactable (i.e. failed Heart Beat).

My problem comes when I try and schedule this procedure. If I run it as an SQL Agent Job it behaves differently. Here, as soon as the error is detected it bombs out stating that the step has failed. I don't mind it stating that the step has failed, what I want it to do is to complete the cursor loop on all the servers. You see at the top of the procedure I set all the heartbeats flags to 0 (i.e. not contactable) so I need to to complete the run. I have search the Agent set-up and can find no flag to stop it halting processes when an error occurs.

The servers are configured not to allow RPC and I would rather not have to put a job on every server to tell me they exist as this would need managing going forward.

Any help you can offer would be greatly appreciated - Happy New Year by the way!

View 4 Replies View Related







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