I don't think black made too many mistakes.
Still all it took was 22 moves for a mate.
Here' the game . Click here
And here's pgn...
1. e4 e5 2. f4 exf4 3. Nf3 d6 4. d4 Be7 5. Bxf4 Bg4 6. Bc4 h6 7. O-O Nf6 8. e5 dxe5 9. Bxe5 O-O 10. c3 Bd6 11. Qb3 Bc8 12. Bxf6 Qxf6 13. Ne5 Qe7 14. Nxf7 Qe3+ 15. Kh1 Kh7 16. Qc2+ g6 17. Nd2 Bf5 18. Rxf5 gxf5 19. Qxf5+ Kg7 20. Qg4+ Kf6 21. Ne4+ Ke7 22. Qe6#
Thursday, September 13, 2007
Thursday, March 22, 2007
pick up random records from a table
Question:
How to pick up random records from a table?
Gabbar:
SELECT TOP 5
*
FROM
tblName
ORDER BY
right(convert(nvarchar(100),((row_number() over (order by ColumnName)) * rand())),3)
This will work in SQL 2005. To make it work in 2000, use any numeric column instead of row_number.
How to pick up random records from a table?
Gabbar:
SELECT TOP 5
*
FROM
tblName
ORDER BY
right(convert(nvarchar(100),((row_number() over (order by ColumnName)) * rand())),3)
This will work in SQL 2005. To make it work in 2000, use any numeric column instead of row_number.
Tuesday, February 06, 2007
Truncate log and shrink all the database
Question:
How to truncate log and shrink the ALL the databases on a SQL Server 2005?
Gabbar:
Create the job with following script....
USE [msdb]
GO
/****** Object: Job [TruncateLogAndShrinkAllDatabases] Script Date: 02/06/2007 15:39:03 ******/
BEGIN TRANSACTION
DECLARE @ReturnCode INT
SELECT @ReturnCode = 0
/****** Object: JobCategory [Database Maintenance] Script Date: 02/06/2007 15:39:03 ******/
IF NOT EXISTS (SELECT name FROM msdb.dbo.syscategories WHERE name=N'Database Maintenance' AND category_class=1)
BEGIN
EXEC @ReturnCode = msdb.dbo.sp_add_category @class=N'JOB', @type=N'LOCAL', @name=N'Database Maintenance'
IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback
END
DECLARE @jobId BINARY(16)
EXEC @ReturnCode = msdb.dbo.sp_add_job @job_name=N'TruncateLogAndShrinkAllDatabases',
@enabled=1,
@notify_level_eventlog=0,
@notify_level_email=0,
@notify_level_netsend=0,
@notify_level_page=0,
@delete_level=0,
@description=N'No description available.',
@category_name=N'Database Maintenance',
@owner_login_name=N'sa', @job_id = @jobId OUTPUT
IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback
/****** Object: Step [TruncateLogShrink] Script Date: 02/06/2007 15:39:03 ******/
EXEC @ReturnCode = msdb.dbo.sp_add_jobstep @job_id=@jobId, @step_name=N'TruncateLogShrink',
@step_id=1,
@cmdexec_success_code=0,
@on_success_action=1,
@on_success_step_id=0,
@on_fail_action=2,
@on_fail_step_id=0,
@retry_attempts=0,
@retry_interval=0,
@os_run_priority=0, @subsystem=N'TSQL',
@command=N'DECLARE @var nvarchar(max)
SET @var = ''''
SELECT
@var = @var +
''
backup log '' + name + '' with truncate_only
DBCC SHRINKDATABASE('''''' + name + '''''')
''
FROM
sys.databases
WHERE
is_read_only = 0
AND database_id > 4
EXEC sp_executesql @var
',
@database_name=N'master',
@flags=0
IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback
EXEC @ReturnCode = msdb.dbo.sp_update_job @job_id = @jobId, @start_step_id = 1
IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback
EXEC @ReturnCode = msdb.dbo.sp_add_jobschedule @job_id=@jobId, @name=N'MidNight',
@enabled=1,
@freq_type=4,
@freq_interval=1,
@freq_subday_type=1,
@freq_subday_interval=0,
@freq_relative_interval=0,
@freq_recurrence_factor=0,
@active_start_date=20070206,
@active_end_date=99991231,
@active_start_time=0,
@active_end_time=235959
IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback
EXEC @ReturnCode = msdb.dbo.sp_add_jobserver @job_id = @jobId, @server_name = N'(local)'
IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback
COMMIT TRANSACTION
GOTO EndSave
QuitWithRollback:
IF (@@TRANCOUNT > 0) ROLLBACK TRANSACTION
EndSave:
How to truncate log and shrink the ALL the databases on a SQL Server 2005?
Gabbar:
Create the job with following script....
USE [msdb]
GO
/****** Object: Job [TruncateLogAndShrinkAllDatabases] Script Date: 02/06/2007 15:39:03 ******/
BEGIN TRANSACTION
DECLARE @ReturnCode INT
SELECT @ReturnCode = 0
/****** Object: JobCategory [Database Maintenance] Script Date: 02/06/2007 15:39:03 ******/
IF NOT EXISTS (SELECT name FROM msdb.dbo.syscategories WHERE name=N'Database Maintenance' AND category_class=1)
BEGIN
EXEC @ReturnCode = msdb.dbo.sp_add_category @class=N'JOB', @type=N'LOCAL', @name=N'Database Maintenance'
IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback
END
DECLARE @jobId BINARY(16)
EXEC @ReturnCode = msdb.dbo.sp_add_job @job_name=N'TruncateLogAndShrinkAllDatabases',
@enabled=1,
@notify_level_eventlog=0,
@notify_level_email=0,
@notify_level_netsend=0,
@notify_level_page=0,
@delete_level=0,
@description=N'No description available.',
@category_name=N'Database Maintenance',
@owner_login_name=N'sa', @job_id = @jobId OUTPUT
IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback
/****** Object: Step [TruncateLogShrink] Script Date: 02/06/2007 15:39:03 ******/
EXEC @ReturnCode = msdb.dbo.sp_add_jobstep @job_id=@jobId, @step_name=N'TruncateLogShrink',
@step_id=1,
@cmdexec_success_code=0,
@on_success_action=1,
@on_success_step_id=0,
@on_fail_action=2,
@on_fail_step_id=0,
@retry_attempts=0,
@retry_interval=0,
@os_run_priority=0, @subsystem=N'TSQL',
@command=N'DECLARE @var nvarchar(max)
SET @var = ''''
SELECT
@var = @var +
''
backup log '' + name + '' with truncate_only
DBCC SHRINKDATABASE('''''' + name + '''''')
''
FROM
sys.databases
WHERE
is_read_only = 0
AND database_id > 4
EXEC sp_executesql @var
',
@database_name=N'master',
@flags=0
IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback
EXEC @ReturnCode = msdb.dbo.sp_update_job @job_id = @jobId, @start_step_id = 1
IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback
EXEC @ReturnCode = msdb.dbo.sp_add_jobschedule @job_id=@jobId, @name=N'MidNight',
@enabled=1,
@freq_type=4,
@freq_interval=1,
@freq_subday_type=1,
@freq_subday_interval=0,
@freq_relative_interval=0,
@freq_recurrence_factor=0,
@active_start_date=20070206,
@active_end_date=99991231,
@active_start_time=0,
@active_end_time=235959
IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback
EXEC @ReturnCode = msdb.dbo.sp_add_jobserver @job_id = @jobId, @server_name = N'(local)'
IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback
COMMIT TRANSACTION
GOTO EndSave
QuitWithRollback:
IF (@@TRANCOUNT > 0) ROLLBACK TRANSACTION
EndSave:
Wednesday, November 15, 2006
याद रक्खूंगा.....
When Gabbar is arrested and being sent to the jail, he meets Thakur on the way and says...
याद रक्खूंगा.....तुझे याद रक्खूंगा.....
The tone of his voice and the hatred in his eyes....लाजवाब!!
याद रक्खूंगा.....तुझे याद रक्खूंगा.....
The tone of his voice and the hatred in his eyes....लाजवाब!!
Monday, October 30, 2006
Thursday, October 19, 2006
मराठीत लिखाण
मी आता मराठी लिहीण्यात चान्गलाच पटाईत झालो आहे.
सुरुवातीला जरा हळू हळू लिहाव लागल, पण आता मात्र वेग आला आहे.
अजून अनुस्वार देता येत नाही.
सुरुवातीला जरा हळू हळू लिहाव लागल, पण आता मात्र वेग आला आहे.
अजून अनुस्वार देता येत नाही.
Thursday, October 12, 2006
Excellent tool for stock market
found this...
Market Heat Map
A very good tool to look at performances of major stocks.
Don't forget to click on options and check the color changes on selection of time periods.
Market Heat Map
A very good tool to look at performances of major stocks.
Don't forget to click on options and check the color changes on selection of time periods.
Wednesday, October 11, 2006
Happy B'Day BigB
Our own BigB reaches 64 today.
Wishing him a very happy B'day and a great year ahead!!!
Excited to watch him play Gabbar.
Wishing him a very happy B'day and a great year ahead!!!
Excited to watch him play Gabbar.
Tuesday, September 26, 2006
Monday, September 25, 2006
Query hierarchical data - SQL 2005
Question:
Table data...
Line Name ForLine
1 Stuff 0
2 SubStuff 1
3 SubSubStuff 2
4 Other 0
5 SubOther 4
6 LowStuff 3
Result required...
Line Name ForLine TopName
3 SubSubStuff 2 Stuff
Gabbar:
WITH MyTree (Line, Name, ForLine, TopName)
AS
(
-- Anchor member definition
SELECT
Line,
Name,
ForLine,
Name as TopName
FROM
MyTable
WHERE
ForLine = 0
UNION ALL
-- Recursive member definition
SELECT
m.Line,
m.Name,
m.ForLine,
t.TopName
FROM
MyTable m
INNER JOIN MyTree t
ON m.ForLine = t.Line
)
SELECT
Line,
Name,
ForLine,
TopName
FROM
MyTree
WHERE
Line = 3
Table data...
Line Name ForLine
1 Stuff 0
2 SubStuff 1
3 SubSubStuff 2
4 Other 0
5 SubOther 4
6 LowStuff 3
Result required...
Line Name ForLine TopName
3 SubSubStuff 2 Stuff
Gabbar:
WITH MyTree (Line, Name, ForLine, TopName)
AS
(
-- Anchor member definition
SELECT
Line,
Name,
ForLine,
Name as TopName
FROM
MyTable
WHERE
ForLine = 0
UNION ALL
-- Recursive member definition
SELECT
m.Line,
m.Name,
m.ForLine,
t.TopName
FROM
MyTable m
INNER JOIN MyTree t
ON m.ForLine = t.Line
)
SELECT
Line,
Name,
ForLine,
TopName
FROM
MyTree
WHERE
Line = 3
Wednesday, September 20, 2006
बराहाचा शोध
छानच लिहीता येते बराहा वापरुन. हा माझा पहिलाच प्रयोग आहे मराठी लिहिन्याचा. ठ लिहीणे जरा जडच गेले.
Tuesday, September 19, 2006
a win .. at last
I thought, I have forgotten how to win a chess game. But no, rising from the ashes, I won this, and that too with white pieces......
1. e4 e6 2. f4 d5 3. Nf3 d4 4. Bc4 c5 5. d3 a6 6. f5 b5 7. fxe6 bxc4 8. exf7+ Kxf7 9. Ne5+ Ke8 10. Qh5+ 11. Nxg6 12. Qe5+ 13. Nxh8 14. Qe6 15. Qf7#
1. e4 e6 2. f4 d5 3. Nf3 d4 4. Bc4 c5 5. d3 a6 6. f5 b5 7. fxe6 bxc4 8. exf7+ Kxf7 9. Ne5+ Ke8 10. Qh5+ 11. Nxg6 12. Qe5+ 13. Nxh8 14. Qe6 15. Qf7#
Wednesday, August 16, 2006
Wednesday, August 09, 2006
Attack with white
Now, I'm not very good with white pieces. Still I managed to do a very good attack in this game. And I loved making the last two moves.
Among the best quick games that I've played.
click here to play through the game.
[Event "Long competition 2"]
[Site "chesshere.com"]
[Date "2006.05.04"]
[White "Gabbar"]
[Black "Zosimo02"]
[Result "1-0"]
[WhiteElo "1497"]
[BlackElo "1504"]
1. e4 e5 2. Nf3 Nc6 3. Bc4 Be7 4. d3 Nf6 5. Nc3 O-O 6. O-O d6 7. Nd5 Nxd5 8. Bxd5 Be6 9. d4 Bg4 10. Qd3 Bxf3 11. Qxf3 Nxd4 12. Qg4 Re8 13. f4 Nxc2 14. fxe5 Nxa1 15. Rxf7 g6 16. Bh6 dxe5 17. Rf8# 1-0
Among the best quick games that I've played.
click here to play through the game.
[Event "Long competition 2"]
[Site "chesshere.com"]
[Date "2006.05.04"]
[White "Gabbar"]
[Black "Zosimo02"]
[Result "1-0"]
[WhiteElo "1497"]
[BlackElo "1504"]
1. e4 e5 2. Nf3 Nc6 3. Bc4 Be7 4. d3 Nf6 5. Nc3 O-O 6. O-O d6 7. Nd5 Nxd5 8. Bxd5 Be6 9. d4 Bg4 10. Qd3 Bxf3 11. Qxf3 Nxd4 12. Qg4 Re8 13. f4 Nxc2 14. fxe5 Nxa1 15. Rxf7 g6 16. Bh6 dxe5 17. Rf8# 1-0
Tuesday, July 25, 2006
फुलले रे ...
फुलले रे क्षण माझे फुलले रे
मेंदीने, शकुनाच्या, शकुनाच्या मेंदीने, सजले रे क्षण माझे सजले रे
झुळूक वार्याची आली रे लेऊन कोवळी सोनफूले
साजण स्पर्शाची जाणिव होऊन, भाळले मन खुळे
या वेडाचे, या वेडाचे, नाचरे भाव बिलोरे
मेंदीने, शकुनाच्या मेंदीने, खुलले रे क्षण माझे खुलले रे
ओढ ही बेबंद, श्वासात, ध्यासात, स्वप्नात येणे तुझे
भांबावल्या माझ्या उरात, स्पर्शात रेशिम काटे तुझे
मनमोराचे, मनमोराचे, जादूभरे हे पिसारे
मेंदीने, शकुनाच्या मेंदीने, हसले रे क्षण माझे हसले रे
प्रीत ही, प्रीत ही उमजेना
जडला का जीव हा समजेना
कशी सांगू मी, कशी सांगू मी
माझ्या मनीची कथा रे
मेंदीने, शकुनाच्या मेंदीने, भुलले रे क्षण माझे भुलले रे
मेंदीने, शकुनाच्या, शकुनाच्या मेंदीने, सजले रे क्षण माझे सजले रे
झुळूक वार्याची आली रे लेऊन कोवळी सोनफूले
साजण स्पर्शाची जाणिव होऊन, भाळले मन खुळे
या वेडाचे, या वेडाचे, नाचरे भाव बिलोरे
मेंदीने, शकुनाच्या मेंदीने, खुलले रे क्षण माझे खुलले रे
ओढ ही बेबंद, श्वासात, ध्यासात, स्वप्नात येणे तुझे
भांबावल्या माझ्या उरात, स्पर्शात रेशिम काटे तुझे
मनमोराचे, मनमोराचे, जादूभरे हे पिसारे
मेंदीने, शकुनाच्या मेंदीने, हसले रे क्षण माझे हसले रे
प्रीत ही, प्रीत ही उमजेना
जडला का जीव हा समजेना
कशी सांगू मी, कशी सांगू मी
माझ्या मनीची कथा रे
मेंदीने, शकुनाच्या मेंदीने, भुलले रे क्षण माझे भुलले रे
Thursday, July 20, 2006
Mate with two bishops
The last pawn was taken on 54th move.
It took me 14 moves to mate the white king.
To play through the chess game, visit chesshere.
Here's the PGN...
[Event "Team Game"]
[Site "chesshere.com"]
[Date "2006.01.02"]
[White "shakkiipe"]
[Black "Gabbar"]
[Result "0-1"]
[WhiteElo "1453"]
[BlackElo "1505"]
1. e4 e5 2. Nf3 Nc6 3. Nc3 Nf6 4. Bb5 Bc5 5. d3 O-O 6. Bg5 h6 7. Bh4 a6 8. Bxc6 dxc6 9. Nxe5 Qd6 10. Nc4 Qf4 11. Bg3 Qg5 12. O-O Bd4 13. Qf3 Bg4 14. Qf4 Rac8 15. Qxg5 hxg5 16. e5 Nh5 17. Rfe1 c5 18. Re4 Bf5 19. Ree1 c6 20. a3 b5 21. Nd6 b4 22. axb4 cxb4 23. Nxc8 Bxc8 24. Nd1 f6 25. e6 Re8 26. e7 Bc5 27. c3 Rxe7 28. Rxe7 Bxe7 29. Ne3 c5 30. Nd5 Bd8 31. cxb4 f5 32. h3 Nxg3 33. fxg3 cxb4 34. Nxb4 a5 35. Nc6 Bb6+ 36. Kf1 Bd7 37. Nxa5 Bd4 38. Nc4 f4 39. gxf4 gxf4 40. Ke2 g5 41. Ra8+ Kg7 42. b4 Bc6 43. Rd8 Bf6 44. Rd6 Bxg2 45. Rd7+ Kg6 46. b5 Bxh3 47. b6 Bxd7 48. b7 f3+ 49. Kf2 Bd4+ 50. Kxf3 Bc6+ 51. Kg4 Bxb7 52. Nd6 Ba6 53. Nf7 Kxf7 54. Kxg5 Bxd3 55. Kf4 Kf6 56. Kf3 Kf5 57. Kg3 Be4 58. Kh4 Be5 59. Kh3 Bf3 60. Kh4 Kf4 61. Kh3 Bf6 62. Kh2 Kg4 63. Kg1 Bh4 64. Kf1 Kh3 65. Kg1 Be2 66. Kh1 Bg5 67. Kg1 Be3+ 68. Kh1 Bf3# 0-1
It took me 14 moves to mate the white king.
To play through the chess game, visit chesshere.
Here's the PGN...
[Event "Team Game"]
[Site "chesshere.com"]
[Date "2006.01.02"]
[White "shakkiipe"]
[Black "Gabbar"]
[Result "0-1"]
[WhiteElo "1453"]
[BlackElo "1505"]
1. e4 e5 2. Nf3 Nc6 3. Nc3 Nf6 4. Bb5 Bc5 5. d3 O-O 6. Bg5 h6 7. Bh4 a6 8. Bxc6 dxc6 9. Nxe5 Qd6 10. Nc4 Qf4 11. Bg3 Qg5 12. O-O Bd4 13. Qf3 Bg4 14. Qf4 Rac8 15. Qxg5 hxg5 16. e5 Nh5 17. Rfe1 c5 18. Re4 Bf5 19. Ree1 c6 20. a3 b5 21. Nd6 b4 22. axb4 cxb4 23. Nxc8 Bxc8 24. Nd1 f6 25. e6 Re8 26. e7 Bc5 27. c3 Rxe7 28. Rxe7 Bxe7 29. Ne3 c5 30. Nd5 Bd8 31. cxb4 f5 32. h3 Nxg3 33. fxg3 cxb4 34. Nxb4 a5 35. Nc6 Bb6+ 36. Kf1 Bd7 37. Nxa5 Bd4 38. Nc4 f4 39. gxf4 gxf4 40. Ke2 g5 41. Ra8+ Kg7 42. b4 Bc6 43. Rd8 Bf6 44. Rd6 Bxg2 45. Rd7+ Kg6 46. b5 Bxh3 47. b6 Bxd7 48. b7 f3+ 49. Kf2 Bd4+ 50. Kxf3 Bc6+ 51. Kg4 Bxb7 52. Nd6 Ba6 53. Nf7 Kxf7 54. Kxg5 Bxd3 55. Kf4 Kf6 56. Kf3 Kf5 57. Kg3 Be4 58. Kh4 Be5 59. Kh3 Bf3 60. Kh4 Kf4 61. Kh3 Bf6 62. Kh2 Kg4 63. Kg1 Bh4 64. Kf1 Kh3 65. Kg1 Be2 66. Kh1 Bg5 67. Kg1 Be3+ 68. Kh1 Bf3# 0-1
Wednesday, July 19, 2006
How to access COM assembly from SQL CLR procedure
Question:
How to access COM assembly from SQL CLR procedure
Gabbar:
1. ALTER DATABASE [MyDatabase] Set TRUSTWORTHY ON
2. CREATE ASSEMBLY VSS FROM 'C:\Microsoft.VisualStudio.SourceSafe.Interop.dll'
WITH PERMISSION_SET = UNSAFE
3. Now, in the add reference window, this dll is visible.
4. Build and Deploy from buid menu option
The catch is, there are 3 permission levels for create assembly
1. SAFE - default mode - cannot access extrnal resource (files/folders)
2. EXTRNAL_ACCESS - can access extrnal resource (files/folders) bu not COM dlls.
3. UNSAFE - can do everything in the world including reference to COM dlls.
The naming of these options...SAFE, UNSAFE doesn't convey much.
But that's true for many microsoft things. :o(
How to access COM assembly from SQL CLR procedure
Gabbar:
1. ALTER DATABASE [MyDatabase] Set TRUSTWORTHY ON
2. CREATE ASSEMBLY VSS FROM 'C:\Microsoft.VisualStudio.SourceSafe.Interop.dll'
WITH PERMISSION_SET = UNSAFE
3. Now, in the add reference window, this dll is visible.
4. Build and Deploy from buid menu option
The catch is, there are 3 permission levels for create assembly
1. SAFE - default mode - cannot access extrnal resource (files/folders)
2. EXTRNAL_ACCESS - can access extrnal resource (files/folders) bu not COM dlls.
3. UNSAFE - can do everything in the world including reference to COM dlls.
The naming of these options...SAFE, UNSAFE doesn't convey much.
But that's true for many microsoft things. :o(
Monday, July 17, 2006
Assembly not found in SQL Catalog
I don't believe this. Searching for my second day now.
All I want to so is create a CLR stored procedure which can access VSS on my own machine. I'm running into this when I try to deploy...
Assembly 'microsoft.visualstudio.sourcesafe.interop, version=5.2.0.0, culture=neutral, publickeytoken=b03f5f7f11d50a3a.' was not found in the SQL catalog.
Is it possible that only a limited pre-listed assemblies can be used for reference in a CLR procedure?
Here's the solution...
All I want to so is create a CLR stored procedure which can access VSS on my own machine. I'm running into this when I try to deploy...
Assembly 'microsoft.visualstudio.sourcesafe.interop, version=5.2.0.0, culture=neutral, publickeytoken=b03f5f7f11d50a3a.' was not found in the SQL catalog.
Is it possible that only a limited pre-listed assemblies can be used for reference in a CLR procedure?
Here's the solution...
Monday, July 10, 2006
Subscribe to:
Posts (Atom)


