Encrypting and Decrypting a Stored Procedure (T-SQL)
-- Create a stored procedure named "sp_test_encryption"
Encrypting and Decrypting a Stored Procedure (T-SQL)
-- Create a stored procedure named "sp_test_encryption"
How to Increase the Maximum allowed Attachment File Size for email using sp_send_dbmail
Solution:
How to login to SQL Server with different OS account?
Solution:
runas /user:domain\new_user "C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\Ssms.exe"
Query First and Last Datetime of This Month (T-SQL):
Let SQL Server tell you which indexes need to rebuild
Here's the SQL script:
SELECT 'ALTER INDEX [' + ix.name + '] ON [' + s.name + '].[' + t.name + '] ' +
A quick way to run multiple SQL files of MSSQL
Suppose we have multiple SQL files of MSSQL to be executed.
SQL Server - sqlcmd example
usage: Sqlcmd [-U login id] [-P password]
[-S server] [-H hostname] [-E trusted connection]
Database Migration Steps from SQL Server 2000 to SQL Server 2005 or 2008
The Following Stored Procedure demonstrates a way to generate a batch file that transfers daily local db backups (db backup & transaction log backups) to a remote site:
-- Transfer db backup
CREATE PROCEDURE sp_transfer_db_backup AS
Rebuild Single or Muitlple Transaction Log Files (SQL Server 2008)
There comes a time when database transaction log files have grown too large,
Problem:
修改Table欄位出現不允許儲存變更 (SQL Server 2008)
OSQL公用程式的使用方法:
OSQL -S 127.0.0.1 -d test_db -E -i C:\test_script\1.txt -o C:\test_script\output_1.txt
快速查詢單一Table(特別是非常龐大資料表)的資料列筆數的SQL語法:
SELECT [RowCount] = MAX(si.rows)
Shrink Transaction Log 的語法:
dump transaction [db] with truncate_only dbcc shrinkfile('[db_log]',1)