我在寫SQL Server中的井字遊戲2008年 這是我到目前爲止有:語法錯誤。如果X CREATE TABLE語句
print '
==========================================================
Tic Tac Toe - SQL Server 2008 - My Name - 10/30/2014
==========================================================
To insert an ''X'', type EXEC pMakeMove row, column, skip.
Row and column must both be between 1 and 3 or you will
automatically forfeit your move. skip can be either 1 or
0, with 1 specifying that you''d like to skip your turn.
You will always start first, unless you decide to skip
your first turn. You will always be ''X'' and the PC will
always be ''O''.
When you make a move, the PC will automatically make a
move as well, the game will check for a winner after
each of these moves.
After each move, the game board is displayed.
On a winning move, the game board is displayed, a
message is displayed, and the board is cleared.
'
if not exists (
select *
from INFORMATION_SCHEMA.TABLES
where TABLE_SCHEMA = 'dbo'
and TABLE_NAME = 'TicTacToe')
begin
create table TicTacToe
(
[row] as int,
[1] as bit,
[2] as bit,
[3] as bit
)
insert into TicTacToe (row,[1],[2],[3]) values (1,null,null,null),(2,null,null,null),(3,null,null,null)
end
else
begin
update TicTacToe set [1]=null,[2]=null,[3]=null
end
這是隨機的錯誤,我'越來越:
Msg 102, Level 15, State 1, Line 31
Incorrect syntax near ')'.
我沒有看到任何明顯的原因。
這迫使我添加更多的細節。這就是你需要的所有細節。 StackOverflow有時候很愚蠢。
我不是SQL服務器專家,但是不應該用分號結束語句嗎? – JNevill 2014-10-30 19:55:42
@Yuck他們很好。這只是寫遊戲的便利。使用'[]'應該使這不成問題。 – KthProg 2014-10-30 19:55:55
@JNevill我在每個語句後都添加了分號,我仍然得到了同樣的錯誤。 – KthProg 2014-10-30 19:56:22