microsoft / microsoft/sqlmanagementobjects

SMO is incorrectly defaulting the schema-identifier, when it shouldn't be (e.g. on CREATE PROCEDURE).

Aperta
#174 3 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Lingua principale
C#
Stelle
143
Fork
28
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

Create a database, e.g. TEST1, and create the following stored-procedure:

CREATE PROCEDURE GetServerName AS BEGIN SELECT @@SERVERNAME END  

Note: no schema identifier was provided above.

Now, in something like SSMS (or Azure Database Studio), whatever, query the stored-procedure (sp) and it clearly states that it belongs to dbo/schema_id=1.

Now, to exercise SMO, use SSMS (or whatever) and generate the SQL to CREATE the sp, and you'll get:

CREATE PROCEDURE [dbo].[GetServerName] AS BEGIN SELECT @@SERVERNAME END 

You'll notice that it's added the schema, [dbo].

I think, that this could actually be a bug. I contend that it shouldn't have added the schema.

Why? Well, apparently it makes a difference . . .

Now, create a second database, e.g. TEST2, and apply the generated sp, then compare, either with (i) Azure Data Studio's "Schema Compare" tool, or (ii) DacFx's SchemaComparison (I assume they are the same thing) and . . . it flags a difference: the SQL it generates for TEST1 doesn't have the schema, but the SQL it generates for TEST2 does have the schema.

My question is: how can I configure SMO options (for calling from C#) to only generate the schema-identifier value it was originally provided (or nothing, if that's the case)? With that, I could run DacFx/SchemaComparison and the two objects would be considered identical.

There could be a little debate as to whether the issue is SMO or DacFx/SchemaComparison, but it seems logical the problem originates in SMO.

Note: the same problem applies to views, UDFs, etc.

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Riproduci il problema con gli script delle stored procedure TEST1 e TEST2, quindi esamina le opzioni di scripting di SMO e il comportamento della sua API per procedure, viste e UDFs. Confronta le definizioni generate con Schema Compare; il lavoro è completato quando uno schema omesso rimane omesso, così che gli oggetti equivalenti non vengano segnalati come diversi.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
csharp, sql
Ambito
databases
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.