Tuesday, 27 April 2010

TSQL: Comma Delimited List from column values

-- SQL 2000, Retrieve desired data
-- With SQL 2000, we will create a User Defined Function to do the concatenation.
-- While this solution can also be used with SQL Server 2005/SQL Server 2008,
-- the previous suggestion is more efficient.
CREATE FUNCTION dbo.fnMakeCommaDelimitedList
( @TempID int )
RETURNS varchar(1000)
AS
BEGIN
DECLARE @TempTable table
( TempValue varchar(20) )
DECLARE @TempList varchar(1000)
SET @TempList = ''
INSERT INTO @TempTable
SELECT DocumentId
FROM TechnicalDocSubscriberDoc
WHERE SubscriberId = @TempID
IF @@ROWCOUNT > 0
UPDATE @TempTable
SET @TempList = ( @TempList + TempValue + ', ' )
RETURN substring( @TempList, 1, ( len( @TempList ) - 1 ))
END

-- Usage
SELECT
ID, contactname, companyname, email, email, companyadd, suburb, state, postcode, contactphoneno,
SubscriberList = dbo.fnMakeCommaDelimitedList( ID )
FROM technicaldocsubscriber
GROUP BY ID, contactname, companyname, email, email, companyadd, suburb, state, postcode, contactphoneno

-- Clean up
DROP FUNCTION dbo.fnMakeCommaDelimitedList

Friday, 16 April 2010

Chrome: Proxy Pac

Our company utilise a proxy pac file for internal users to access the outside world.

For chrome you'll need to add the following extensions:

"drive:\chrome install location\chrome.exe" --proxy-pac-url="http://proxypacurl/proxy.pac"

OTHER proxy example settings:

You will have to use command-line flags to override.
These are the ones available:

--no-proxy-server
--proxy-auto-detect
--proxy-bypass-list=XXX
--proxy-pac-url=XXX
--proxy-server=XXX

See the source code for documentation.

For example:

Send all traffic through the SOCKS 5 server "foobar:1080"
chrome --proxy-server="socks5://foobar:1080"

Send all traffic through the HTTP proxy server "foo:6233"
chrome --proxy-server="foo:6233"

Use the custom PAC script to resolve proxy servers:
chrome --proxy-pac-url="file:///home/foobar/tmp/myscript.js"

Thursday, 8 April 2010

ASP: HTTP Headers for CSV filetypes

// these headers avoid IE problems when using https:
// see http://support.microsoft.com/kb/812935

header("Cache-Control: must-revalidate");
header("Pragma: must-revalidate");

header("Content-type: application/vnd.ms-excel");
header("Content-disposition: attachment; filename=$filename.csv");