microsoft / microsoft/sqlmanagementobjects
[Bug]: Script as Create does not provide valid script
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- C#
- Estrellas
- 143
- Forks
- 28
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
Description
I cannot use Script as Create for tables in Azure SQL Database, as if I do I get errors as seen in the screenshot below.
Here is the original script:
CREATE TABLE transporter.CompanyProfile (
CompanyProfileId int NOT NULL CONSTRAINT PK_transporter_CompanyProfile PRIMARY KEY IDENTITY(1,1),
CompanyId int NOT NULL,
CONSTRAINT FK_CompanyProfile_CompanyId
FOREIGN KEY (CompanyId) REFERENCES transporter.Company(CompanyId),
ProfileId int NOT NULL,
CONSTRAINT FK_CompanyProfile_ProfileId
FOREIGN KEY (ProfileId) REFERENCES auth.Profile(ProfileId),
Active bit NOT NULL,
UpdatedDate DATETIME2 NOT NULL,
UpdatedBy int NOT NULL,
CONSTRAINT FK_CompanyProfile_UpdatedBy
FOREIGN KEY (UpdatedBy) REFERENCES auth.Profile(ProfileId),
ValidFrom DATETIME2 GENERATED ALWAYS AS ROW START NOT NULL,
ValidTo DATETIME2 GENERATED ALWAYS AS ROW END NOT NULL,
PERIOD FOR SYSTEM_TIME (ValidFrom, ValidTo)
)
WITH (SYSTEM_VERSIONING = ON (HISTORY_TABLE = transporter.CompanyProfileHistory));
Here is the script generated using Script as Create:
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [transporter].[CompanyProfile](
[CompanyProfileId] [int] IDENTITY(1,1) NOT NULL,
[CompanyId] [int] NOT NULL,
[ProfileId] [int] NOT NULL,
[Active] [bit] NOT NULL,
[UpdatedDate] [datetime2](7) NOT NULL,
[UpdatedBy] [int] NOT NULL,
[ValidFrom] [datetime2](7) GENERATED ALWAYS AS ROW START NOT NULL,
[ValidTo] [datetime2](7) GENERATED ALWAYS AS ROW END NOT NULL,
PERIOD FOR SYSTEM_TIME ([ValidFrom], [ValidTo])
) ON [PRIMARY]
WITH
(
SYSTEM_VERSIONING = ON (HISTORY_TABLE = [transporter].[CompanyProfileHistory])
)
GO
ALTER TABLE [transporter].[CompanyProfile] ADD CONSTRAINT [PK_transporter_CompanyProfile] PRIMARY KEY CLUSTERED
(
[CompanyProfileId] ASC
)WITH (STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ONLINE = OFF, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
GO
ALTER TABLE [transporter].[CompanyProfile] WITH CHECK ADD CONSTRAINT [FK_CompanyProfile_CompanyId] FOREIGN KEY([CompanyId])
REFERENCES [transporter].[Company] ([CompanyId])
GO
ALTER TABLE [transporter].[CompanyProfile] CHECK CONSTRAINT [FK_CompanyProfile_CompanyId]
GO
ALTER TABLE [transporter].[CompanyProfile] WITH CHECK ADD CONSTRAINT [FK_CompanyProfile_ProfileId] FOREIGN KEY([ProfileId])
REFERENCES [auth].[Profile] ([ProfileId])
GO
ALTER TABLE [transporter].[CompanyProfile] CHECK CONSTRAINT [FK_CompanyProfile_ProfileId]
GO
ALTER TABLE [transporter].[CompanyProfile] WITH CHECK ADD CONSTRAINT [FK_CompanyProfile_UpdatedBy] FOREIGN KEY([UpdatedBy])
REFERENCES [auth].[Profile] ([ProfileId])
GO
ALTER TABLE [transporter].[CompanyProfile] CHECK CONSTRAINT [FK_CompanyProfile_UpdatedBy]
GO
Here are the errors when I run the generated script:
Steps to Reproduce
Scripts are provided above.
Affected Area
- Connection dialog (SQL Server | Azure browse/Fabric browse)
- Query results panel
- Query editor
- Object Explorer
- Table Designer
- Schema Compare
- Schema Designer
- Local SQL Server Container provisioning
- SQL database in Fabric provisioning
- GitHub Copilot integration
- Query Plan Visualizer
- Other (please describe below)
If you selected "Other", please describe the affected area
Generated Scripts
Environment Information
Visual Studio Code: Version 1.104.1 (Universal)
Extension SQL Server (mssql): v1.36.0
MacOS 15.6.1
Azure SQL
Confirmation
- I have searched existing issues and couldn't find a match
- I want to work on this issue
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Use los scripts CREATE TABLE original y generado del informe como reproducción, comenzando con la ruta de generación Script as Create para tablas temporales de Azure SQL. Compare la salida generada con el origen y, a continuación, verifique que el script corregido se ejecute correctamente y conserve las restricciones de clave primaria y clave foránea.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- azure, csharp, sql
- Área
- database, tooling
- Tipo de issue
- Error
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 35/100