Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Running value but with a string
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  6 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
philipbennett25  
View profile  
 More options Nov 5, 9:04 am
Newsgroups: microsoft.public.sqlserver.programming
From: philipbennett25 <pbenn...@xyratex.com>
Date: Wed, 4 Nov 2009 14:04:49 -0800 (PST)
Local: Thurs, Nov 5 2009 9:04 am
Subject: Running value but with a string
Searched the group, but didnt really know what this would be called. I
want to make a growing string based on value from previous rows, eg:

---------------------
Row  :  Y/N
---------------------
1           Y
2           N
3           Y
4           Y

Becomes

-------------------------------
Row  :  Y/N  :  String
-------------------------------
1           Y
2           N       YN
3           Y       YNY
4           Y       YNYY

and so on.

Any help would be much appreciated.

Thanks -Phil


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Plamen Ratchev  
View profile  
 More options Nov 5, 9:13 am
Newsgroups: microsoft.public.sqlserver.programming
From: Plamen Ratchev <Pla...@SQLStudio.com>
Date: Wed, 04 Nov 2009 17:13:42 -0500
Local: Thurs, Nov 5 2009 9:13 am
Subject: Re: Running value but with a string
Here is one example:

CREATE TABLE Foo (
  fookey INT NOT NULL PRIMARY KEY,
  y_n CHAR(1));

INSERT INTO Foo VALUES(1, 'Y');
INSERT INTO Foo VALUES(2, 'N');
INSERT INTO Foo VALUES(3, 'Y');
INSERT INTO Foo VALUES(4, 'Y');

SELECT A.fookey, A.y_n,
       (SELECT '' + B.y_n
        FROM Foo AS B
        WHERE B.fookey <= A.fookey
        ORDER BY B.fookey
        FOR XML PATH('')) AS yn_path
FROM Foo AS A;

/*

fookey      y_n  yn_path
----------- ---- ---------
1           Y    Y
2           N    YN
3           Y    YNY
4           Y    YNYY

*/

DROP TABLE Foo;

--
Plamen Ratchev
http://www.SQLStudio.com


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
--CELKO--  
View profile  
 More options Nov 7, 2:11 pm
Newsgroups: microsoft.public.sqlserver.programming
From: --CELKO-- <jcelko...@earthlink.net>
Date: Fri, 6 Nov 2009 19:11:19 -0800 (PST)
Local: Sat, Nov 7 2009 2:11 pm
Subject: Re: Running value but with a string

>>  I want to make a growing string based on value from previous rows,<<

In RDBMS, there is no such concept as a "previous row" because sets
have no ordering.  This is going to lead to some stinking kludges with
cursors, XML and other non-relational and/or proprietary code.  Or
horrible recursive code.

This ought to be in VIEW so that a change in the rows will cascade, if
you insist in throwing out First Formal Form.

The right answer is to do this in the front end.


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tony Rogerson  
View profile  
 More options Nov 7, 11:28 pm
Newsgroups: microsoft.public.sqlserver.programming
From: "Tony Rogerson" <tonyroger...@torver.net>
Date: Sat, 7 Nov 2009 12:28:30 -0000
Local: Sat, Nov 7 2009 11:28 pm
Subject: Re: Running value but with a string

> have no ordering.  This is going to lead to some stinking kludges with
> cursors, XML and other non-relational and/or proprietary code.  Or
> horrible recursive code.

Plamen has done what is required in 7 lines of T-SQL.

Hardly horrible but certainly maintainable.

By narrowing your solutions into pure 100% ansi standard SQL you are just
costing your client money because has you have just stated, you will need to
not only consider writing SQL but also you will need further skills in
writing in a programming langauge say C for instance which is the only one
that is widely used and has a standard implementation. I've not even started
to mention the costs in terms of testing, releasing and supporting these
additional items your chosen solution would mandate.

What is the correct solution - well, in business the investment will have
been made in the product SQL Server so to get the maximum return on that
investment you aren't going to hire another programmer just because you want
to stay "portable" - and I use that term loosely because any professional
out there will tell you portability is not something that is really
achievable.

I bet people actually laugh at you once you've left the building; or more to
the point - do you actually do any real consulting in the Microsoft field?
Or is it all just as I expect adhoc training a couple of times a year?

--ROGGIE--

"--CELKO--" <jcelko...@earthlink.net> wrote in message

news:d7ed98a9-a5a7-405c-b422-0620b2818e7c@r24g2000prf.googlegroups.com...


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
--CELKO--  
View profile  
 More options Nov 8, 11:29 am
Newsgroups: microsoft.public.sqlserver.programming
From: --CELKO-- <jcelko...@earthlink.net>
Date: Sat, 7 Nov 2009 16:29:37 -0800 (PST)
Local: Sun, Nov 8 2009 11:29 am
Subject: Re: Running value but with a string

You narrow your solutions by writing in dialect; you increase their
scope, maintainability and robustness by sticking to Standards.
Having something that runs in only one release of one version of one
SQL is not a good thing.

But strong dialect code gives you job security.  Even better, write
your code in an unsupported version that only you know.

I have never worked anywhere that the whole system was in SQL; there
is always a front end language of some kind --C#, Cobol, Java, PHP,
etc.  The front end languages do their job far better than SQL.  I do
not want to screens with just a PRINT statement in T-SQL.

Also, the company is going to get another programmer unless you plan
on staying forever or they fail in a short time.  A professional
programmer knows that 80% of the total cost of a system is in
maintaining it, we write code for the poor SOB who comes after us.


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tony Rogerson  
View profile  
 More options Nov 8, 7:51 pm
Newsgroups: microsoft.public.sqlserver.programming
From: "Tony Rogerson" <tonyroger...@torver.net>
Date: Sun, 8 Nov 2009 08:51:59 -0000
Local: Sun, Nov 8 2009 7:51 pm
Subject: Re: Running value but with a string

> You narrow your solutions by writing in dialect; you increase their
> scope, maintainability and robustness by sticking to Standards.

Wrong - the standards a small subset of the product language available
within MICROSOFT SQL SERVER.

> Having something that runs in only one release of one version of one
> SQL is not a good thing.

Wrong again - we've already been through this one; there are very few items
of syntax that have been deprecated - legacy code written on SQL Server 6.5
still works on SQL Server 2008 - that allows business to migrate versions of
SQL Server without having to rewrite everything.

The same cannot be said for the sql standard where items have been
withdrawn.

> But strong dialect code gives you job security.  Even better, write
> your code in an unsupported version that only you know.

No - job security comes from writing maintainable code that costs very
little to support and that doesn't use anything that isn't documented in
books online for SQL Server.

> I have never worked anywhere that the whole system was in SQL; there
> is always a front end language of some kind --C#, Cobol, Java, PHP,
> etc.  The front end languages do their job far better than SQL.  I do
> not want to screens with just a PRINT statement in T-SQL.

Of those languages you just mentioned only Cobol has a standard
implementation - Cobol is not widely used in today's environment - basically
anything written in the last 10 years is either .NET (C#), Java or PHP.
There is almost certainly a large legacy world of PL/1 and COBOL code on the
mainframe but that set now pales into insignificance compared to what is out
there in today's client server environment.

You are just being silly - screens with just PRINT - even the mention you
are subconsciously admitting you know I'm right on this point out in the
real world.

7 lines of code V 2 languages requiring 2 developers, 2 teams of people -
more testing, different types of testing, a different release mechanism -
builds that require deploying to the desktop.

I'd go with the 7 lines of the single SQL statement any day and anybody with
any common sense and exposure to a REAL WORKING ENVIRONMENT would do the
same.

If you don't understand the concepts of supportability and maintainability
then go back to school because you missed several classes.

> Also, the company is going to get another programmer unless you plan
> on staying forever or they fail in a short time.  A professional
> programmer knows that 80% of the total cost of a system is in
> maintaining it, we write code for the poor SOB who comes after us.

Precisely...
7 lines of 1 single SQL statement

V

a completely separate program written in C requiring a completely separate
developer rather than your in house DBA team.

I do wish sometimes you would read and understand your own statement "A
professional programmer knows that 80% of the total cost of a system is in
maintaining it, we write code for the poor SOB who comes after us." because
then you would stop post unmaintable and unsupportable solutions like
passing 1000 parameters to a stored procedure, like insisting that the
product only be used as a store / retrieve with 100% standard sql, do I go
on???

To end, the crux of the matter here is that because you've come straight out
of university and gone straight into training, article writing and book
writing you think that all the theory you learn't applies and works directly
in the business environment - shock horror - it doesn't - do you honestly
realise how stupid you look on this forum and in the industry now?

I was talking to a friend yesterday about you and some of the crap you come
out with and without prompting he said your trouble (you that is) is that
you are stuck 15 years ago - you've not moved whereas the rest of us have.
In fact, in another 5 years time I bet you are coming out with the same old
crap; luckily this forum is getting less and less busy and people are
getting their posts answered in the moderated forums in MS now and across
twitter - so, in 5 years time I very much doubt you'll have a platform to
spout garbage and insult every poster who posts - I look forward to that
day!

--ROGGIE--

"--CELKO--" <jcelko...@earthlink.net> wrote in message

news:b4b6e36a-8271-49b3-a954-c207eba58904@f18g2000prf.googlegroups.com...


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google