You can easily run Transact-SQL (T-SQL) script files (with extension .sql) via the commandline utility sqlcmd:
sqlcmd -S Server\Instance -i C:\path\to\SomeScript.sql
By default, the output is written to the command prompt. You can also save the output to a file:
sqlcmd -S Server\Instance -i C:\path\to\SomeScript.sql -o C:\path\to\TheOutput.txt
Note that when using this, no output is written in the command prompt window.
Download links for SQL Server 2012 Service Pack 3, including Express edition:
A bit hard to find through the search on Microsoft website, so here's the direct link:
https://www.microsoft.com/en-us/download/details.aspx?id=46697
You can easily move the table to another filegroup by recreate the clustered index on the table:
CREATE CLUSTERED INDEX CIX_YourTable ON dbo.YourTable(YourClusteringKeyFields) WITH DROP_EXISTING ON [filegroup_name]
If the clustered index is unique:
CREATE UNIQUE CLUSTERED INDEX CIX_YourTable ON dbo.YourTable(YourClusteringKeyFields) WITH DROP_EXISTING ON [filegroup_name]
This creates a new clustered index and drops the old one. Because the new index is created in the other filegroup, the table will have been moved to that filegroup.
When restoring a database, you usually start with restoring a full backup, then any differentials, and finally the transaction logs. You set the database restore mode to WITH NORECOVERY, which allows you to perform these additional restores.
But what if you find out that there's nothing more to restore, leaving you with a database stuck in Restoring mode? Then you only need to run a single T-SQL statement:
RESTORE DATABASE [db_name] WITH RECOVERY
Replace db_name with the name of your database.
Follow the chart below to successfully perform a rolling upgrade of your HA SQL Server cluster.
Probably MSSQL 101, but this is how to quickly retrieve the structure of a table:
EXEC sp_help tbl_name GO
tbl_name is the name of the table.
« ‹ | November 2024 | › » | ||||
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |