Welcome to Sign in | Help

Re: update pe un field

  •  01-21-2008, 9:00 PM

    Re: update pe un field

    De asemenea, ce sens are IF-ul din WHILE daca conditia este indentică ?
    Cursorul poate fi FORWARD_ONLY (implicit DYNAMIC) si modificarile le poti realiza folosind comanda UPDATE ... WHERE CURRENT OF ...

    Daca toate campurile se regasesc in aceeasi tabela atunci poti apela la o solutie de tipul:
    CREATE TABLE [dbo].[Angajat](
      [Id] [int] NOT NULL,
      [Nume] [varchar](50) NOT NULL,
      [Prenume] [varchar](50) NOT NULL,
      [Departament] [varchar](50) NOT NULL,
      [ToText] AS (((([Nume]+' ')+[Prenume])+', dep:')+[Departament]),
    CONSTRAINT [PK_Angajat] PRIMARY KEY CLUSTERED
    (
      [Id] ASC
    )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
    ) ON [PRIMARY]
    --eventual definesti campul calculat ToText ca fiind
    PERSISTED
    GO

    INSERT INTO Angajat VALUES (1,'ION','IONESCU','FINANCIAR')
    INSERT INTO Angajat VALUES (2,'POPA','POPESCU','FINANCIAR')
    INSERT INTO Angajat VALUES (3,'VASILE','VASILESCU','CONTABILITATE')

    GO

    SELECT * FROM Angajat

    In situatia in care campurile Nume, Prenume, Departament se regasesc in tabele diferite (de ex. ai o tabela Angajat si o alta tabela Departament) atunci poti să defineşti o tabelă virtuală / vedere (en. view) folosind comanda CREATE VIEW.
View Complete Thread
Powered by Community Server (Commercial Edition), by Telligent Systems