x002548's Blog

Not Just a Number - Brett Kaiser
posts - 89, comments - 586, trackbacks - 39

June 2006 Blog Posts

How do I create a file with a header and trailer?

...was recently asked at SQLTeam http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=68461 This is what I would do USE NorthwindGO CREATE VIEW EXPORT_ORDERSASSELECT 1 AS ROW_ORDER,   'HEADER '  + CONVERT(char(25),GetDate()) AS Data_LineUNION ALLSELECT 2 AS ROW_ORDER,   COALESCE(CONVERT(char(15),OrderID),'') + COALESCE(CustomerID,'') + COALESCE(CONVERT(char(15),EmployeeID),'') + COALESCE(CONVERT(char(25),OrderDate),'') + COALESCE(CONVERT(char(25),RequiredDate),'') + COALESCE(CONVERT(char(25),ShippedDate),'') + COALESCE(CONVERT(char(15),ShipVia),'') + COALESCE(CONVERT(char(15),Freight),'') + COALESCE(CONVERT(char(80),ShipName),'') + COALESCE(CONVERT(char(120),ShipAddress),'') + COALESCE(CONVERT(char(30),ShipCity),'') + COALESCE(CONVERT(char(30),ShipRegion),'') + COALESCE(CONVERT(char(20),ShipPostalCode),'') + COALESCE(CONVERT(char(30),ShipCountry),'') AS Data_Line  FROM OrdersUNION ALLSELECT 3 AS ROW_ORDER,  'TRAILER '  + CONVERT(char(25),GetDate()) + CONVERT(char(15),COUNT(*)) AS Data_Line  FROM OrdersGO SELECT Data_Line FROM EXPORT_ORDERS ORDER BY ROW_ORDER EXEC master..xp_cmdshell 'bcp Northwind.dbo.EXPORT_ORDERS out C:\Orders.txt -S<servername> -c -T'GO DROP VIEW EXPORT_ORDERSGO

posted @ Thursday, June 29, 2006 1:03 PM | Feedback (2) | Filed Under [ SQL Server ]

OSQL Doesn't work like Query Analyzer ( Or Query Analyser for that matter...)

What?  Huh?  This can't be...can it?  Well this person seemed to think so: http://www.dbforums.com/showthread.php?t=1219537 I didn't think that this was possible...and, well, it isn't...so I am posting this for future reference....and to start blogging all things SQL again USE NorthwindGO CREATE TABLE myTable99(Col1 int)GO INSERT INTO myTable99(Col1)SELECT 1    UNION ALLSELECT 2    UNION ALLSELECT 3    UNION ALLSELECT null UNION ALLSELECT null UNION ALLSELECT nullGO CREATE PROC mySproc99 @Rows int OUTPUT AS SELECT @Rows = COUNT(*) FROM myTable99 WHERE Col1 IS NULLGO DECLARE @Rows intEXEC mySproc99 @Rows OUTPUTSELECT @Rows DECLARE @cmd varchar(8000), @sql varchar(8000)SELECT @sql = 'DECLARE @Rows int EXEC mySproc99 @Rows OUTPUT SELECT @Rows'SELECT @cmd = 'osql -U sa -P...

posted @ Monday, June 26, 2006 12:57 PM | Feedback (6) | Filed Under [ SQL Server ]

Sidekick? What the hell is a sidekick?

At first I thought it was a Suzuki... http://www.edmunds.com/new/suzuki/index.html?mktcat=makemodel-suzuki&kw=suzuki+sidekick&mktid=ga471651 I was like, Damn they left their suzuki in a taxi...wait, let me read that again..So this is what it is http://www.amazon.com/gp/product/B0000A0AZC/103-5355719-0187859?v=glance&n=301185 In my opinion, people are going too crazy with these things...don't they know they are becoming automoton slaves? In any event Graz posted this link in the corral.  I'd figure I'd add to the mayhem http://www.evanwashere.com/StolenSidekick/ Another voice of reason http://impulse100.net/StolenSidekick/viewtopic.php?t=47 EDIT: 6/13/2006  Ok, who wouldn't have guessed where this was going “WHAT THE HELL?    So she SOLD our Sidekick...  After we had contacted her.  So either that's why she needed the money, to buy it BACK, or she...

posted @ Thursday, June 08, 2006 4:18 PM | Feedback (13) | Filed Under [ Disconnected Ramblings ]

Powered by:
Powered By Subtext Powered By ASP.NET