Skip to content

SSMS – get DDL of all views in a schema

I have a SQL Server database with several schemas, each of them contains several views. I need to create the same views in other databases so I would like to get the DDL of all the views in a script, generated through SQL. In Oracle it was quite easy, accessing ALL_VIEWS and referencing the QUERY column. How …

How to aggregate and group by in each column?

I have this table: I’d like to summarize major and minor columns to get this result: Is there any way to achieve this? I tried: But it didn’t count each number. Answer You may achieve this using window functions. major minor major_count minor_count A a 3 2 A b 3 1 B c 2 1 B d 2 1 View

How to query and filter relation entity in room database

For example: User: Post: Data if i use SELECT * FROM user i got the desire data(a user and all posts), but how can i filter the post for a specific type, like WHERE post.type = ‘sth’ is that possible? Answer but how can i filter the post for a specific type, It depends on exactly what you want to