Repository: dbeaver/dbeaver
Issue: Azure Synapse Serverless: cannot read view definition

#### System information: 
- Windows 10
- DBeaver 22.0.3

#### Connection specification:
- Database type: Azure Synapse "serverless"
- Driver name: Azure SQL Server
- No tunnels or proxies

#### Describe the problem you're observing:
Trying to get the DDL of a view produces a NullPointerException and the definition pane shows:
```
/* ERROR WHILE READING SOURCE:

null
*/
```

In version 22.0.0, view definitions could be obtained, see #15490.

#### Steps to reproduce, if exist:
- Open a view object in this type of database
- Go to Properties -> Definition

#### Include any warning/errors/backtraces from the logs
Exception stack trace:

java.lang.NullPointerException
	at org.jkiss.dbeaver.model.DBUtils.getQuotedIdentifier(DBUtils.java:78)
	at org.jkiss.dbeaver.ext.mssql.edit.SQLServerViewManager.createOrReplaceViewQuery(SQLServerViewManager.java:115)
	at org.jkiss.dbeaver.ext.mssql.edit.SQLServerViewManager.addObjectDeleteActions(SQLServerViewManager.java:91)
	at org.jkiss.dbeaver.model.impl.sql.edit.SQLObjectEditor$ObjectDeleteCommand.getPersistActions(SQLObjectEditor.java:401)
	at org.jkiss.dbeaver.model.impl.sql.edit.struct.SQLTableManager.getTableDDL(SQLTableManager.java:224)
	at org.jkiss.dbeaver.model.struct.DBStructUtils.generateTableDDL(DBStructUtils.java:89)
	at org.jkiss.dbeaver.model.struct.DBStructUtils.getTableDDL(DBStructUtils.java:116)
	at org.jkiss.dbeaver.model.struct.DBStructUtils.generateTableListDDL(DBStructUtils.java:176)
	at org.jkiss.dbeaver.ui.editors.sql.SQLSourceViewer.getSourceText(SQLSourceViewer.java:95)
	at org.jkiss.dbeaver.ui.editors.sql.SQLEditorNested$ObjectDocumentProvider$1.lambda$0(SQLEditorNested.java:279)
	at org.jkiss.dbeaver.model.exec.DBExecUtils.tryExecuteRecover(DBExecUtils.java:171)
	at org.jkiss.dbeaver.ui.editors.sql.SQLEditorNested$ObjectDocumentProvider$1.run(SQLEditorNested.java:277)
	at org.jkiss.dbeaver.model.runtime.AbstractJob.run(AbstractJob.java:105)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)

Session data:

eclipse.buildId=unknown
java.version=11.0.12
java.vendor=Eclipse Foundation
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en
Command-line arguments:  -os win32 -ws win32 -arch x86_64

Connection test shows:

Server:
    Microsoft SQL Server 12.00.214
    Microsoft SQL Azure (RTM) - 12.0.2000.8 
    Mar 31 2022 08:13:33 
Driver:
    Microsoft JDBC Driver 9.2 for SQL Server 9.2.0.0

Output of `SELECT SERVERPROPERTY('EngineEdition')`: 11

`SELECT definition FROM sys.sql_modules WHERE object_id = (OBJECT_ID(N'your_shema_name.your_view_name'))` (adapted to existing schemas and views, obviously) gives no results.

Changed files:
plugins/org.jkiss.dbeaver.ext.mssql/src/org/jkiss/dbeaver/ext/mssql/edit/SQLServerViewManager.java

diff --git a/plugins/org.jkiss.dbeaver.ext.mssql/src/org/jkiss/dbeaver/ext/mssql/edit/SQLServerViewManager.java b/plugins/org.jkiss.dbeaver.ext.mssql/src/org/jkiss/dbeaver/ext/mssql/edit/SQLServerViewManager.java
index 0a6428e52c..10b8537007 100644
--- a/plugins/org.jkiss.dbeaver.ext.mssql/src/org/jkiss/dbeaver/ext/mssql/edit/SQLServerViewManager.java
+++ b/plugins/org.jkiss.dbeaver.ext.mssql/src/org/jkiss/dbeaver/ext/mssql/edit/SQLServerViewManager.java
@@ -97,7 +97,8 @@ public class SQLServerViewManager extends SQLServerBaseTableManager<SQLServerVie
     {
         SQLServerDatabase procDatabase = view.getContainer().getDatabase();
         SQLServerDatabase defaultDatabase = ((SQLServerExecutionContext)executionContext).getDefaultCatalog();
-        if (defaultDatabase != procDatabase) {
+        boolean addUse = defaultDatabase != null && procDatabase != null && defaultDatabase != procDatabase;
+        if (addUse) {
             actions.add(new SQLDatabasePersistAction("Set current database", "USE " + DBUtils.getQuotedIdentifier(procDatabase), false)); //$NON-NLS-2$
         }
 
@@ -113,7 +114,7 @@ public class SQLServerViewManager extends SQLServerBaseTableManager<SQLServerVie
                 break;
         }
 
-        if (defaultDatabase != procDatabase) {
+        if (addUse) {
             actions.add(new SQLDatabasePersistAction("Set current database ", "USE " + DBUtils.getQuotedIdentifier(defaultDatabase), false)); //$NON-NLS-2$
         }
     }