Re: Creating db from SQL statements

Tech-Archive recommends: Fix windows errors by optimizing your registry



in sqlserver use int for integers and identity (which is a property not a datatype) for serial (there is no ansi version)


CREATE TABLE foobar_def(
id int identity PRIMARY KEY,
fkid int references sometable(id)
NOT NULL ON DELETE CASCADE,
name varchar(32) NOT NULL,
kval int CHECK (kval between 1 and 3) NOT NULL
);

CREATE INDEX fb_idx ON foobar_def (name, kval);

-- bruce (sqlwork.com)

Grey Alien wrote:
I have created a database (*.df) file for use with my website. I have files containing DDL and DDM for creating the db schema and stored procedures respectively. However, I have not (as yet) founs out how to "import" the SQL statements into the datbase, to create the required database objects. I would appreciate any help/info that will help me generate the db objects from the SQL statements.

Additionally, I need to 'port' my SQL from PostgreSQl to SQL Server SQL. I would like to use ANSI-SQL as much as possible, and avoid using SQL specific SQL wherever possible. My tables typically look something like this:

CREATE TABLE foobar_def(
id SERIAL PRIMARY KEY,
fkid integer references sometable(id) NOT NULL ON DELETE CASCADE,
name varchar(32) NOT NULL,
kval integer CHECK (kval between 1 and 3) NOT NULL
);

CREATE INDEX fb_idx ON foobar_def (name, kval);


What would be the equivalent syntax to create this table (and index) in SQL Server?


Any one has links to the SQL Server SQL guide ?
.



Relevant Pages

  • Re: eliminate unnecessary joint in the view
    ... select val1 from view1x2x3 ... There are situations where SQL Server will realise that a table is not ... CREATE TABLE Table1(Key1 int NOT NULL PRIMARY KEY, ...
    (microsoft.public.sqlserver.programming)
  • Re: Executing Stored Proc from file in Ado .NET
    ... Here is a snippit of one of the SQL script: ... DECLARE @CORE_CORE3572301500_release_exists INT ... SET TRANSACTION ISOLATION LEVEL SERIALIZABLE ... SO someone tell me what am i doing wrong, I'm talking directly to SQL Server ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Views vs Stored Procedures, whats the difference?
    ... I'm just trying to differentiate between two fundamentally different SQL objects. ... CREATE TABLE P(pk INT NOT NULL PRIMARY KEY, ... SELECT MAXFROM nestedview ...
    (comp.databases.ms-sqlserver)
  • Re: looping
    ... Oracle - this is a problem requiring an answer that works on SQL Server. ... id), id, salesperson_id, tran_date, clear_date, amount, ... from Trans t2 ... salesperson_id int not null, ...
    (microsoft.public.sqlserver.programming)
  • Re: Field locked on one SQL record
    ... InspectionNum -- int ... The form is a simple entry form that gives the user an "Inspection Number" ... can only write once to the Note field. ... On the SQL server and in the Access project there are no relationships set ...
    (microsoft.public.access.adp.sqlserver)