SQL Server 2005 Generated Create Table Script not working

后端 未结 7 2230
遇见更好的自我
遇见更好的自我 2021-01-06 00:00

I\'m in the process of creating database scripts for an existing database. I\'m trying to use SQL Server to generate the scripts for me, but the generated scripts are faili

相关标签:
7条回答
  • 2021-01-06 00:10

    I get this exact same problem when i use SQL Server Management Studio 2005 to generate a Create Table script on a SQL Server 2000 database.

    0 讨论(0)
  • 2021-01-06 00:11

    If your target DB is SQL 2000 then it complains about this line

    WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
    

    SQL 2000 only supports

    WITH FILLFACTOR = 90
    

    So there is probably some compatibility setting you can use to only generate SQL 2000 syntax

    0 讨论(0)
  • 2021-01-06 00:13

    If you are running this on a SQL Server 2000 database I believe it has code in it that SQL Server 2000 does not support. I've never seen a SQL SErver 2000 script that sets up the constraint as part of the table definition.

    0 讨论(0)
  • 2021-01-06 00:18

    With the exception of the use [MyDatabase] statement (I changed it to tempdb), this statement executes correctly when I run it against SQL Server 2005 using Microsoft SQL Server Management Studio.

    0 讨论(0)
  • 2021-01-06 00:19

    I've got the same error. SQL Sever Management Studio defaults to generate scripts for SQL Server 2005, which are not compatible with 2000.

    My solution: In SQL Sever Management Studio, go to Tools>>Options>>Scripting. Under "General Scripting Options, set "Script for server version" to "SQL Server 2000".

    0 讨论(0)
  • 2021-01-06 00:20

    I copied/pasted this exact SQL statement and it executed properly for me. The only thing I can think is that you have something highlighted and it is executing only that portion of it (which may not be a complete statement).

    0 讨论(0)
提交回复
热议问题