Invalid primary key datatype [int] - sql-server-2000

I am using Afo Castle AR Code Generator v1.0.0.4 at first I was receiving errors for using tinyint as a primary key so I changed those to int but the only error I have left and can't seem to get rid of is
Invalid primary key datatype [int] for
table dbo.Level_Code. Only int
identity and uniqueidentifier primary
keys are supported in the free
version.
The field is already an int in the database. I even tried changing it from an int to tinyint and then back but that still doesn't work.
Any suggestions?

The error message says it only supports an autogenerating int key. Make the int an identity as well and you should be fine.

Related

Can't create graph tables with sqlproj

After getting really fed up with using hierarchyids to manage my node tree, I decided to take a stab at using SQL Server 2017's graph functionality to ease my troubles.
I have a little bit of confusion, though. Currently, all of my SQL scripts are stored and organized in a SQL database project. When I create a node table and publish it to my Azure SQL Database, it only creates a standard table.
However, I can paste the exact same query into SSMS and it creates the graph table just fine. I've included the query below. Am I missing anything obvious?
CREATE TABLE [dbo].[GraphSite]
(
[SiteId] UNIQUEIDENTIFIER NOT NULL DEFAULT NEWID(),
[SiteName] NVARCHAR(100) NOT NULL,
[SiteTypeId] UNIQUEIDENTIFIER NOT NULL,
[SiteTimeZone] NVARCHAR(20) NOT NULL DEFAULT N'America/New_York',
[SiteStatusId] UNIQUEIDENTIFIER NULL,
[SiteThemeId] UNIQUEIDENTIFIER NULL,
CONSTRAINT [PK_GraphSite] PRIMARY KEY ([SiteId]),
CONSTRAINT [FK_GraphSite_SiteType] FOREIGN KEY ([SiteTypeId]) REFERENCES [SiteType]([SiteTypeId]),
CONSTRAINT [FK_GraphSite_SiteStatus] FOREIGN KEY ([SiteStatusId]) REFERENCES [SiteStatus]([SiteStatusId]),
CONSTRAINT [FK_GraphSite_SiteTheme] FOREIGN KEY ([SiteThemeId]) REFERENCES [SiteTheme]([SiteThemeId])
) AS NODE;
EDIT: I installed SQL Server 2017 locally and it leaves "AS NODE;" in fine. So SSDT seems to have an issue building graph tables to Microsoft Azure SQL Database v12. Which is weird, considering Azure SQL databases fully support graph tables. Any thoughts?
Could you try downloading the latest version of SSDT from here: https://learn.microsoft.com/en-us/sql/ssdt/download-sql-server-data-tools-ssdt
This should fix the problem for you.

Wrong executed SQL Statement error

TL;DR: How do I make the table refresh with the new, updated columns?
Hi, I'm getting an error which states that I have invalid column names. The column names which are invalid have been deleted before hand and updated then.
When I refresh the table's data, the error is displayed again stating: SELECT TOP [1000], Error Source: .Net SqlClient Data Provider and the invalid column names.
The error is straight forward, but how do I manage to change the "default" refresh query of the table? I checked the table from SQL Managment Studio and Visual Studio and everything seems right... it's just that this query is not adapting to the update which I done to the table. This table had a foreign key with another table but I'm sure that I deleted any links with other tables.
Just in case this is the code of the table:
CREATE TABLE [dbo].[Receipt] (
[receiptID] INT IDENTITY (1, 1) NOT NULL,
[employeeUser] NVARCHAR (50) NULL,
[purchasedProductID] INT NULL,
[productName] NVARCHAR (50) NULL,
[clientID] INT NULL,
PRIMARY KEY CLUSTERED ([receiptID] ASC)
);
Thanks alot and take care!
SOLVED
Apparently the "Did you try turning it on/off" method work sometimes...
I restarted my visual studio project and worked.

How to set a primary key using SQL

I have this table 'Cars', attributes:
MODEL nvarchar(20)
STYLE nvarchar(20)
ENGINE nvarchar(5)
CAPACITY smallint
MAX_SPEED smallint
PRICE smallmoney
MARKET nvarchar(20)
COMPETITOR nvarchar(20)
I would like to set 'PRICE' as the primary key via a SQL sStatement, so I've tried:
ALTER TABLE Cars
ADD PRIMARY KEY (PRICE)
But I just get the error
The ALTER TABLE SQL construct or statement is not supported.
in Visual Studio 2010.
As has been said above, price is a bad primary key. But ... the correct syntax to do what you are trying to do is:
ALTER TABLE Cars
ADD CONSTRAINT cars_pk PRIMARY KEY (PRICE)
Visual studio is not a database client. If you want to run any query at all, you have to use a client that allows you to do so. The details depend on the database engine you are using.
If you want to do this with Visual Studio, you have to send that command, as a query, the same way you would send a select query. Once again, the details depend on your database engine.
Something else that depends on the database engine is the syntax of the command itself. Some will allow what you tried. Other will make you use the constraint keyword.
Finally, as mentioned in the comments, price is a poor choice for the primary key. Better choices would be a uuid, an autoincrementing integer, or, the VIN.

DokuWiki and SQL code

I recently installed DokuWiki on my domain and ran in one nasty problem.
I am trying to enter such code:
CREATE TABLE LOOM(
ID INT NOT NULL,
KIIP_ID INT NOT NULL,
NIMI VARCHAR(50) NOT NULL,
SYND DATE NOT NULL,
SURM DATE,
PRIMARY KEY (ID));
between tags and if I am trying to preview or save the change, DokuWiki shows me this:
This topic does not exist yet
You've followed a link to a topic that doesn't exist yet. If permissions allow, you may create it by using the Create this page button.
How to fix this?
See http://www.dokuwiki.org/faq:mod_security
You should escape the commands between the <code></code> tags. Like the below.
<code>
CREATE TABLE LOOM(
ID INT NOT NULL,
KIIP_ID INT NOT NULL,
NIMI VARCHAR(50) NOT NULL,
SYND DATE NOT NULL,
SURM DATE,
PRIMARY KEY (ID));
</code>
If you still have problems previewing then Andreas is right it is most likely a web server configuration issue with Apache. To validate that you could redploy on nginx and see if the issue still persists. I have a tutorial about deploying dokuwiki on nginx here: http://bigthinkingapplied.com/launching-a-private-wikipedia-using-dokuwiki/

create table in ibatis with array data type

I'm trying to use ibatis with HSSQL to create a table in an in memory database at runtime but using the following returns an error, presumably because the square brackets confuse Ibatis, which results in a SQLException: Incorrect syntax near 'ARRAY'
CREATE TABLE GROUPS (id INT PRIMARY KEY, members bigint ARRAY DEFAULT ARRAY[])
I tried escaping in XML like this but got the same error:
<![CDATA[ CREATE TABLE MATCHGROUPS (id INT PRIMARY KEY, groupid bigint ARRAY DEFAULT ARRAY[], members bigint ARRAY DEFAULT ARRAY[]) ]]>
Anyone know a way to work around this? I'd like to keep the design consistent and not resort to a raw query for this case if possible. I've checked that the sql runs fine in HSSQL manager so it's the right sql syntax.
Thanks in advance
The CDATA excape actually does work, I discovered a mistake I made somewhere else that was causing the misleading error!