Skip site navigation (1) Skip section navigation (2)

Re: scripts de sql convertir a postgresql

From: Jenaro Centeno Gómez <jcenteno(at)aldia(dot)com(dot)mx>
To: lnto_27(at)yahoo(dot)com
Cc: pgsql-es-ayuda(at)postgresql(dot)org
Subject: Re: scripts de sql convertir a postgresql
Date: 2008-08-26 17:26:22
Message-ID: 48B43CBE.7030901@aldia.com.mx (view raw or flat)
Thread:
Lists: pgsql-es-ayuda
Luis Nieto escribió:
> saludos
>
> me pueden ayudar a convertir este scripts que esta hecho en sqlserver
> necesito para un proyecto, o si me puedes informar de una herramientas 
> que me permita convertir a un scripts de postgresql... no importa si 
> no lo hace en su totalidad pero me puede servir cualquier informacion 
> que me puedan brindar...
>
> /************************************************************/
> /*****              Initialization Script               *****/
> /*****                                                  *****/
> /*****                                                  *****/
> /***** Note: To manually execute this script you must   *****/
> /*****       perform a search and replace operation     *****/
> /*****       for {databaseOwner} and {objectQualifier}  *****/
> /*****                                                  *****/
> /************************************************************/
>
> if exists (select * from dbo.sysobjects where id = 
> object_id(N'Version') and OBJECTPROPERTY(id, N'IsTable') = 1)
> begin
>   if '{objectQualifier}' <> ''
>   begin
>     EXECUTE sp_rename N'{databaseOwner}Version', 
> N'{objectQualifier}Version', 'OBJECT'
>     EXECUTE sp_rename N'PK_Version', N'PK_{objectQualifier}Version', 
> 'OBJECT'
>     EXECUTE sp_rename N'IX_Version', N'IX_{objectQualifier}Version', 
> 'INDEX'
>
>     ALTER TABLE {databaseOwner}{objectQualifier}Version ADD CONSTRAINT
>     IX_{objectQualifier}Version UNIQUE NONCLUSTERED
>     (
>     Major,
>     Minor,
>     Build
>     ) ON [PRIMARY]
>   end
> end
> else
> begin
>   if not exists (select * from dbo.sysobjects where id = 
> object_id(N'{objectQualifier}Version') and OBJECTPROPERTY(id, 
> N'IsTable') = 1)
>   begin
>     CREATE TABLE {databaseOwner}{objectQualifier}Version (
>       [VersionId] [int] IDENTITY (1, 1) NOT NULL ,
>         [Major] [int] NOT NULL ,
>       [Minor] [int] NOT NULL ,
>       [Build] [int] NOT NULL ,
>       [CreatedDate] [datetime] NOT NULL
>     ) ON [PRIMARY]
>
>     ALTER TABLE {databaseOwner}{objectQualifier}Version WITH NOCHECK ADD
>       CONSTRAINT [PK_{objectQualifier}Version] PRIMARY KEY  CLUSTERED
>       (
>         [VersionId]
>       )  ON [PRIMARY]
>
>     ALTER TABLE {databaseOwner}{objectQualifier}Version ADD CONSTRAINT
>     IX_{objectQualifier}Version UNIQUE NONCLUSTERED
>     (
>     Major,
>     Minor,
>     Build
>     ) ON [PRIMARY]
>
>   end
> end
> GO
>
> if exists (select * from dbo.sysobjects where id = 
> object_id(N'{objectQualifier}GetDatabaseVersion') and 
> OBJECTPROPERTY(id, N'IsProcedure') = 1)
> drop procedure {databaseOwner}{objectQualifier}GetDatabaseVersion
> GO
>
> create procedure {databaseOwner}{objectQualifier}GetDatabaseVersion
>
> as
>
> select Major,
>        Minor,
>        Build
> from   {objectQualifier}Version
> where  VersionId = ( select max(VersionId) from {objectQualifier}Version )
>
> GO
>
> if exists (select * from dbo.sysobjects where id = 
> object_id(N'{objectQualifier}FindDatabaseVersion') and 
> OBJECTPROPERTY(id, N'IsProcedure') = 1)
> drop procedure {databaseOwner}{objectQualifier}FindDatabaseVersion
> GO
>
> create procedure {databaseOwner}{objectQualifier}FindDatabaseVersion
>
> @Major  int,
> @Minor  int,
> @Build  int
>
> as
>
> select 1
> from   {objectQualifier}Version
> where  Major = @Major
> and    Minor = @Minor
> and    Build = @Build
>
> GO
>
> if exists (select * from dbo.sysobjects where id = 
> object_id(N'{objectQualifier}UpdateDatabaseVersion') and 
> OBJECTPROPERTY(id, N'IsProcedure') = 1)
> drop procedure {databaseOwner}{objectQualifier}UpdateDatabaseVersion
> GO
>
> create procedure {databaseOwner}{objectQualifier}UpdateDatabaseVersion
>
> @Major  int,
> @Minor  int,
> @Build  int
>
> as
>
> insert into {objectQualifier}Version (
>   Major,
>   Minor,
>   Build,
>   CreatedDate
> )
> values (
>   @Major,
>   @Minor,
>   @Build,
>   getdate()
> )
>
> GO
>
> de antemano gracias por su respuesta.... me podrian enviar a mi email....
>
> attt
>
> luis
>
>
> ------------------------------------------------------------------------
>
> Yahoo! MTV Blog & Rock
> ¡Cuéntanos tu historia, inspira una canción y gánate un viaje a los 
> Premios MTV!
> Participa aquí http://mtvla.yahoo.com/ 
Creo que por ahí circula una herramienta llamada "Cerebro", hay varias 
versiones con varias capacidades. :D

Ya en serio, dale una leída al manual. Y si tienes dudas entonces preguntas.

http://www.postgresql.org/docs/8.3/interactive/index.html

Saludos.


In response to

pgsql-es-ayuda by date

Next:From: Gilberto Castillo MartínezDate: 2008-08-26 19:27:51
Subject: [Probablemente Spam] Re: [Off-topic] Jornadas Regionales Soft LIbre
Previous:From: Luis NietoDate: 2008-08-26 16:58:55
Subject: scripts de sql convertir a postgresql

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group