2014. február 5., szerda

First steps in the Not Only SQL world

The first Cassandra db was be installed on my PC. The OpsCenter was launched and the first (test) node was created. But OpsCenter didn't work bacause agents failed to ssh to the node.

I got three suggested change in different settings to fix this. I did all of them and the issue was be fixed. My Cassandra runs on Windows 7(x64).

Add this line(s) (or update them) to the file below:

1. addres.yaml
  use_ssl: 0
2. local.conf
  conf_location = C:\Program Files\DataStax Community\apache-cassandra\conf\cassandra.yaml (check the path!)
3. opscenterd.conf
  [agents]
   ssh_port = 2222

All the files can be found under the folder 'Program Files\DataStax Community'.

2013. június 13., csütörtök

Launch PS from Windows Explorer

It's just peanuts but very useful.

  • If you type powershell in the addressbar of Windows Explorer (ALT + D), you will get a PS console with prompt of current directory.
  • If you type it ii . (Invoke-Item .) in a PS console, it will navigate you in the Windows Explorer to the current directory.
I stole these tricks from a stackoverflow topic.

2013. május 28., kedd

PowerShell és SQL Server prezentáció



Tegnap megtartottam életem első prezentációját a PowerShell és az SQL kapcsolatáról. És túléltem :) A helyszínt a LogMeIn biztosította, a rendezvényt pedig az SQLPASS local chapter HUG-MSSQL (Horvát Zoli) szervezte. Így az első előadásom egyben az első SQLPASS előadásom is!

PS and SQL
Az előadás diáit innen tudjátok letölteni.

2013. május 7., kedd

Egy remek passz

A HUG-MSSQL a PASS tagja lett!

Egy éve írtam egy posztot anno a Horváth Zoli által szervezett SQL meetupokról, hát mit mondjak, szépen kinőtte magát a csoport. Hurrá és grat! :)

Az első PASS-os előadás május 29-én lesz, el ne felejtsétek! :)

2013. március 23., szombat

Msg 11305

Execute a query on SQL Server 2008 such as this:
  1. SELECT COUNT (ItemID) OVER (ORDER BY OrderID) FROM OrderDetails;
You get the following error message:

Msg 11305, Level 15, State 10, Line 1
The Parallel Data Warehouse (PDW) features are not enabled.

Really? Thank you for telling me but what can I do now?

OK, the reason of failure is simple. ORDER BY in OVER clause on an aggregate function works only in version 2012. But this message doesn't help much in debugging.

2012. augusztus 24., péntek

Mennyi az idő?

Mai villámkérdésünk: az alábbi kódban mi lehet a @num változó két szélső értéke (min/max)?

DECLARE @date datetime, @num float
SET @date = @num

És ha a @date típusa datetime2?

2012. augusztus 21., kedd

Update csavarral


Mi a történik  akkor, ha egy tábla rekordjait rangsorolnám, és ezt a rangsort rögzíteném is a tábla egy új 
oszlopában? Mondjuk így:
  1. UPDATE Buildings SET nRank = ROW_NUMBER() OVER (ORDER BY nHeight);  
Ez történik:

Windowed functions can only appear in the SELECT or ORDER BY clauses.

Szóval csak SELECT vagy ORDER BY. Szerencsére ez nem olyan nagy gond. Használhatunk CTE-t, beágyazott query-t vagy view-t, és már teljesítettük is a fenti megkötést. Hogy pontosan hogyan, az ebből a script-sorból kiderül. A CTE-s verziót be is kopizom ide (szerintem ez a legelegánsabb).

  1. WITH Ranking AS  
  2. (  
  3. SELECT  
  4.       nRank  
  5.       ,ROW_NUMBER() OVER (ORDER BY nHeight) AS nComputedRank  
  6. FROM  
  7.       Buildings  
  8. )  
  9.   
  10. UPDATE  
  11.       Ranking  
  12. SET  
  13.       nRank = nComputedRank;  
Nagy rekordszám esetén érdemes elgondolkodni egy indexelt temp tábla használatán. A lemezre írásnak ugyan van költsége, de lehet, hogy ezt az indexek miatt bőven behozzuk az update-nél.