SQL Server Forum / DB Engine / SQL Server / February 2008
create table script
|
|
Thread rating:  |
Rupesh Mondal - 27 Feb 2008 06:40 GMT I am creating table in sql server 2005, by using the below script,but it showing "syntax error near (" The below script is created from generate script option of sql) ,I ll apprecite the solution asap,Thanx guys
SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[UserRoles]( [UserRoleID] [int] IDENTITY(1,1) NOT NULL, [UserID] [int] NOT NULL, [RoleID] [int] NOT NULL, [ExpiryDate] [datetime] NULL, [IsTrialUsed] [bit] NULL, [EffectiveDate] [datetime] NULL, CONSTRAINT [PK_UserRoles] PRIMARY KEY CLUSTERED ( [UserRoleID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY]
Tibor Karaszi - 27 Feb 2008 07:38 GMT I assume that you by "it showing "syntax error near ("" Mean that when you execute the script from some tool you get that error message? If so, can you specify what tool you use to execute the script and against what version of SQL Server. Also, make sure you do not mark any text when you execute it, or that you do mark only the text you want to be executed.
 Signature Tibor Karaszi, SQL Server MVP http://www.karaszi.com/sqlserver/default.asp http://sqlblog.com/blogs/tibor_karaszi
>I am creating table in sql server 2005, by using the below script,but it > showing "syntax error near (" The below script is created from generate [quoted text clipped - 17 lines] > OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] > ) ON [PRIMARY] Rupesh Mondal - 27 Feb 2008 10:27 GMT I am not using any kind of tool, i am executing it from query analyzer of sql server 2005 standard ediion
> I assume that you by "it showing "syntax error near ("" Mean that when you execute the script from > some tool you get that error message? If so, can you specify what tool you use to execute the script [quoted text clipped - 22 lines] > > OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] > > ) ON [PRIMARY] Tibor Karaszi - 27 Feb 2008 11:00 GMT >I am not using any kind of tool, i am executing it from query analyzer of sql > server 2005 standard ediion Then that tool would be query analyzer (or perhaps you meant SQL Server Management Studio).
Anyhow, I executed the code you posted and it worked just fine. I'm also on SQL Server 2005. My guess is that you by mistake maked a part of the text so that only that text were submitted to sQL Server.-
 Signature Tibor Karaszi, SQL Server MVP http://www.karaszi.com/sqlserver/default.asp http://sqlblog.com/blogs/tibor_karaszi
>I am not using any kind of tool, i am executing it from query analyzer of sql > server 2005 standard ediion [quoted text clipped - 27 lines] >> > OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] >> > ) ON [PRIMARY] Tom Cooper - 27 Feb 2008 15:00 GMT Another posibility is that the server/instance you are running this against is SQL 2000, not SQL 2005. The syntax you are usingis only valid on SSQL 2005. Try running
Select ServerProperty('ProductVersion')
If it returns a value where the first digit is 8, like 8.00.2039 then it is SQL 2000 and that is your problem.
But if it returns a value where the first digit is 8, like 9.00.3042.00 then it is SQL2005 and my guess is incorrect.
But if it is SQL 2000, then the entire clause WITH (...) is not valid syntax and should be removed.
Tom
> >I am not using any kind of tool, i am executing it from query analyzer of > >sql [quoted text clipped - 42 lines] >>> > OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] >>> > ) ON [PRIMARY] Rupesh Mondal - 29 Feb 2008 12:28 GMT Thanks, u r correct,but is there any other way, means if i can change any configuration in sql server 2005 so that it works, or any other way or should i uninstall sql 2000
Thank u
> Another posibility is that the server/instance you are running this against > is SQL 2000, not SQL 2005. The syntax you are usingis only valid on SSQL [quoted text clipped - 60 lines] > >>> > OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] > >>> > ) ON [PRIMARY] Tom Cooper - 29 Feb 2008 17:07 GMT If you use the SSMS scripts wizard to generate the script for the table, you can tell it to generate a script that is compatable with SQL 2000. On the Choose Scripts Options page there is an option named Script for Server Version. Set that to SQL 2000 and it will generate a script that will run on SQL 2000. Of course, if you are using features that are new for SQL 2005, those features won't be included.
Tom
> Thanks, u r correct,but is there any other way, means if i can change any > configuration in sql server 2005 so that it works, or any other way or [quoted text clipped - 77 lines] >> >>> > OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] >> >>> > ) ON [PRIMARY]
|
|
|