-2

this is my code:

--Vedere care conține clienții ce au inchiriat camere:

USE Sunset

GO

CREATE VIEW  vedere1 AS

SELECT DISTINCT c.Nume AS num_client, r.Nr_camera AS camera, f.Data_emiterii, f.Suma

FROM factura f, clienti c, camera r

WHERE (f.Id_client=c.Id_client) AND (r.Id_client=c.Id_client)

GO

and this is my error: There is already an object named 'vedere1' in the database

what should I do?

Arion
  • 31,011
  • 10
  • 70
  • 88

4 Answers4

1

As the error message says, you are trying to create a view with a name that already exists in your database.

If you want to modify/change it, use alter instead of create.

If you want to create new view, change the name of the view.

mridula
  • 3,203
  • 3
  • 32
  • 55
0

As the error says, that object may already exist. does select * from vedere1

return anything?

If so use the following script if you REALLY want to overwrite the existing View. --Vedere care conține clienții ce au inchiriat camere:

USE Sunset

GO

ALTER VIEW vedere1 AS

SELECT DISTINCT c.Nume AS num_client, r.Nr_camera AS camera, 
f.Data_emiterii, f.Suma

FROM factura f, clienti c, camera r

WHERE (f.Id_client=c.Id_client) AND (r.Id_client=c.Id_client)

GO
NotADog
  • 159
  • 1
  • 9
0

Just double check there is not also a table with this name- this was my issue when the same error appeared.

0

You have already have a vedere1 view.

Majid Parvin
  • 4,499
  • 5
  • 29
  • 47