SQLCMD QUERY
Without SSMS using Sqlcmd to check table and execute sql query
Windows Credencial :
sqlcmd -S KCSPL0455\SQLEXPRESS2017 -d QuestionBank -E -q "SELECT * FROM dbo.tbl_AnswerDetails"
Sql Credencial :
sqlcmd -S KCSPL0455\SQLEXPRESS2017 -d QuestionBank -U user -P pass -q "SELECT * FROM TABLE"
Execute SQL Script File:
sqlcmd -S KCSPL0455\SQLEXPRESS -i D:\script.sql
Attach database file .mdf & .ldf file:
sp_attach_db "BookingSystem","C:\Booking Management System\BookingSystem.mdf","C:\Booking Management System\BookingSystem_log.ldf"
detach database :
sp_detach_db "BookingSystem";
Attach/Detach Database in SQL Server using sqlcmd
Goto cmd (Run->cmd)
sqlcmd -S .\
sqlcmd -S localhost\SQLEXPRESS
sqlcmd -S REMOTEMACHINE\INSTANCENAME
After connecting switch to master database
use master;
go
Then you should see – Changed database context to ‘master’.
Now attach/detach your database
sp_detach_db "database name";
go
sp_attach_db "database name","path to mdf","path to ldf";
go
sp_attach_db "AHCF","D:\AHCF_Installation\AHCF.mdf","D:\AHCF_Installation\AHCF_log.ldf"
use "database name"
go
sp_helpfile
go