|
Home > Archive > MS SQL Server > March 2006 > Prefixing
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
| Shawnmb 2006-03-24, 3:23 am |
| Hey everybody,
I've never had to write a script of this sort, so any help would
greatly be appreciated.
I'm looking to "prefix" every entry in a certain column, for example
lets use column "test2".
The data I have is "1" then "2" then "3". How could I append a "k" for
example; to the beginning of each of these (output: "k1", "k2", "k3")?
The actual database this will end up being run on will have over
150,000 entries in the column being prefixed.
Thanks in advance,
Shawn
| |
| Tibor Karaszi 2006-03-24, 3:23 am |
| Do you want to modify the data stored in the tables or do you just want to return this information
in a SELECT statement?
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www. solidqualitylearning
.com/
"Shawnmb" <Shawnmb@gmail.com> wrote in message
news:1143184289.627990.8750@g10g2000cwb.googlegroups.com...
> Hey everybody,
> I've never had to write a script of this sort, so any help would
> greatly be appreciated.
> I'm looking to "prefix" every entry in a certain column, for example
> lets use column "test2".
> The data I have is "1" then "2" then "3". How could I append a "k" for
> example; to the beginning of each of these (output: "k1", "k2", "k3")?
> The actual database this will end up being run on will have over
> 150,000 entries in the column being prefixed.
>
> Thanks in advance,
> Shawn
>
| |
| Jack Vamvas 2006-03-24, 7:26 am |
| If you want to UPDATE existing data :
UPDATE myTable SET myCol = 'k'+myCol
If you just want to use it as a SELECT statement : and keep the data in its
present format:
SELECT output = 'k'+myCol FROM myTable
--
Jack Vamvas
____________________
_______________
Receive free SQL tips - www.ciquery.com/sqlserver.htm
"Shawnmb" <Shawnmb@gmail.com> wrote in message
news:1143184289.627990.8750@g10g2000cwb.googlegroups.com...
> Hey everybody,
> I've never had to write a script of this sort, so any help would
> greatly be appreciated.
> I'm looking to "prefix" every entry in a certain column, for example
> lets use column "test2".
> The data I have is "1" then "2" then "3". How could I append a "k" for
> example; to the beginning of each of these (output: "k1", "k2", "k3")?
> The actual database this will end up being run on will have over
> 150,000 entries in the column being prefixed.
>
> Thanks in advance,
> Shawn
>
| |
| Shawnmb 2006-03-25, 3:23 am |
| Thanks for the responses, that was just what I was seeking. A second
related question, let's say the data in the column is numericial? How
would I add one to each row, not in front but to the actual number?
| |
| Jack Vamvas 2006-03-27, 7:25 am |
| Similar idea , but if it was a the column data type was numerical , it would
be :
UPDATE myTable SET myCol = myCol + 1
If you just want to use it as a SELECT statement : and keep the data in its
present format:
SELECT output = myCol + 1 FROM myTable
--
Jack Vamvas
____________________
_______________
Receive free SQL tips - www.ciquery.com/sqlserver.htm
"Shawnmb" <Shawnmb@gmail.com> wrote in message
news:1143277159.490186.111980@v46g2000cwv.googlegroups.com...
> Thanks for the responses, that was just what I was seeking. A second
> related question, let's say the data in the column is numericial? How
> would I add one to each row, not in front but to the actual number?
>
|
|
|
|
|