Last active
February 15, 2024 17:16
-
-
Save malbarmavi/d2722bedc2f02ea2e4e62a6cd3f97c5b to your computer and use it in GitHub Desktop.
MS SQL Server Most Useful Queries
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select * from master.dbo.sysdatabases; | |
use DataBaseName; | |
select * from information_schema.tables; | |
select TABLE_NAME 'Table Name',COUNT(COLUMN_NAME) 'Column Count' | |
from information_schema.COLUMNS group by TABLE_NAME order by [TABLE_NAME]; | |
select @@CONNECTIONS; | |
select @@SERVERNAME; | |
select @@SERVICENAME; | |
select @@VERSION; | |
--http://stackoverflow.com/questions/42648/best-way-to-get-identity-of-inserted-row | |
select @@IDENTITY; | |
select SCOPE_IDENTITY(); | |
select IDENT_CURRENT('tableName') ; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment