Skip to content

my-study-area/estudo-sql-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

estudo-sql-server

# inicia o container com sql server
docker-compose up -d

# acessa sqlcmd
docker-compose exec sqlserver /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 1234@abcd

Para restaurar um banco de dados no Azure Data Studio realize os seguintes passos:

docker cp db-data/AdventureWorksDW2019.bak  estudo-sql-server-sqlserver-1:/mnt/
# download dos backups: https://github.com/Microsoft/sql-server-samples/releases/tag/adventureworks
-- cria banco de dados
CREATE database ESTUDOSQLSERVER;

-- lista os banco de dados
SELECT name, database_id, create_date  
FROM sys.databases;

-- lista as tabelas
SELECT * FROM sys.tables;

-- lista os campos das tabelas
SELECT * FROM information_schema.COLUMNS WHERE TABLE_NAME='TABELA DE CLIENTES';

-- descreve as colunas da tabela
exec sp_help 'TABELA DE CLIENTES'
exec sp_columns 'TABELA DE CLIENTES'


-- mostra a quantidade de linhas por tabela
SELECT t.name TableName, i.rows Records
FROM sysobjects t, sysindexes i
WHERE t.xtype = 'U' and i.id = t.id and i.indid in (0,1)
ORDER BY Records DESC

Links

About

Estudo SQL Server

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published