SELECT *
FROM myTable
ORDER BY NEWID()
Friday, March 25, 2011
Randomly Ordering a ResultSet in SQL Server
-- I found this T-SQL function to be quite handy. It returns the records in a random order every time.
Getting Access to the Response Object from a Regular C# Class (and NOT a code-behind)
When I attempt to call Response.Write() or Response.Redirect() from a genuine C# class (NOT a code-behind), I get an interesting error:
"Response is not available in this context."
However, call it this way and it should work fine:
"Response is not available in this context."
However, call it this way and it should work fine:
HttpContext.Current.Response.Write("Hello, World!");
Query to Retrieve Uptime from a SQL Server
SELECT DATEDIFF(D, CrDate, GETDATE()) 'Days On Line'
FROM SysDatabases
WHERE Name = 'TempDb'
Labels:
SQL Server Administration,
T-SQL
Location:
Columbus, GA, USA
Wednesday, March 16, 2011
Getting Column Names from a Table in SQL Server
-- All table info
SELECT *
FROM INFORMATION_SCHEMA.Columns
WHERE TABLE_NAME = 'tblName'
-- Column Info
SELECT COLUMN_NAME, DATA_TYPE
FROM INFORMATION_SCHEMA.Columns
WHERE TABLE_NAME = 'tblName'
Labels:
SQL Server Administration,
T-SQL
Location:
Columbus, GA, USA
Thursday, March 10, 2011
Html/Meta Object in C#
Don't forget to import System.Web.UI.HtmlControls;
//Waits for 10 seconds and then forwards to Google.com
HtmlMeta meta = new HtmlMeta();
meta.HttpEquiv = "Refresh";
meta.Content = "10; URL=http://www.google.com";
Page.Header.Controls.Add(meta);
Location:
Columbus, GA, USA
Thursday, March 3, 2011
Moving System Databases in SQL Server 2008
Great article on this. Follow it to the letter from start to finish though, or you could wind up with a non-functioning SQL Server:
Moving System Databases
Moving System Databases
Labels:
SQL Server Administration
Location:
Columbus, GA, USA
Change the Default Database File Path
USE [master]
GO
EXEC xp_instance_regwrite N'HKEY_LOCAL_MACHINE',
N'Software\Microsoft\MSSQLServer\MSSQLServer', N'DefaultData',
REG_SZ, N'S:\DATA'
GO
EXEC xp_instance_regwrite N'HKEY_LOCAL_MACHINE',
N'Software\Microsoft\MSSQLServer\MSSQLServer', N'DefaultLog',
REG_SZ, N'L:\SQLLog'
GO
Default Database File Path
Labels:
SQL Server Administration,
T-SQL
Location:
Columbus, GA, USA
Code: 0x80012017 Description: The package path referenced an object that cannot be found
From the command line run this:
REGSVR32 "C:\Program Files\Microsoft SQL Server\90\DTS\Binn\DTS.dll"
Make sure that the path in quotations is where the DTS.dll is stored.
Maintenance Plan Failure
REGSVR32 "C:\Program Files\Microsoft SQL Server\90\DTS\Binn\DTS.dll"
Make sure that the path in quotations is where the DTS.dll is stored.
Maintenance Plan Failure
Labels:
SQL Server Administration
Location:
Columbus, GA, USA
Tuesday, March 1, 2011
Subscribe to:
Posts (Atom)