Re: Update statement



On 28 Apr 2006 00:10:17 -0700, Munno wrote:

Hi All,

I am not so proficient in SQL and seek your help.

I have a column by the name of Mask in a table, which has text eg.
(YYYYYYYNNNNYYYYYYYYYNNYYYY). I wanted to update one particular value
in that text. How would my update statement look like?

Below is my select statement.

select user, substring(mask, 50, 1) Authorisation from users where type
= 1 order by Authorisation desc

Below statement doesn't work.

update users set substring(mask, 50, 1) = 'Y' where user = 'me'

Regards,

Hi Munno,

Recommendation: redesign the table. This design is a violation of first
normal form ("one value per column")

Quick kludge to get you running until yoou find the time to fix the
design: check out the STUFF function in Books Online.

UPDATE users
SET mask = STUFF(mask, 50, 1, 'Y')
WHERE user = 'me'

--
Hugo Kornelis, SQL Server MVP
.



Relevant Pages

  • Update statement
    ... I am not so proficient in SQL and seek your help. ... I have a column by the name of Mask in a table, ... How would my update statement look like? ... select user, substringAuthorisation from users where type ...
    (comp.databases.ms-sqlserver)
  • Update Statement
    ... I am not so proficient in SQL and seek your help. ... I have a column by the name of Mask in a table, ... How would my update statement look like? ... select user, substringAuthorisation from users where type ...
    (comp.databases.ms-sqlserver)
  • Re: SQL
    ... > If you design right, you can *shift* much behavior to being data and ... > SQL is close to being Turing Complete. ... It is a bad habit of yours. ... If you're seriously suggesting that CRUD applications are equal ...
    (comp.object)
  • Re: Object-oriented thinking in SQL context?
    ... away from arrays and other non-OO data structures associated ... SQL is constrained to 'trivial' arrays. ... Design: Logical Design", 4th edition. ... Something analogous happens with database design. ...
    (comp.databases.theory)
  • Re: Why does 1:3 relationsihp require another table?
    ... Pro SQL Server 2000 Database Design ... > there can be a relation with NULLs in its tuples (hence 1NF models with ... > can only conclude that you do not believe Louis and Lewis are correctly ...
    (microsoft.public.sqlserver.programming)