TSQL Scripts

Post Reply
tony.malandain
Posts: 57
Joined: Sat Mar 27, 2004 6:39 pm

TSQL Scripts

Post by tony.malandain »

Hi,

I'm trying to write a small SQL Script to run using TSQL -i <scriptName>
I'd like to add some comments in the script but so far I've been unable to find the right syntax.
I tried the /* */, //, #, ' and others, but no luck.
Does TSQL support comments in the scripts?

Thanks,
/Tony.
User avatar
mark
Site Admin
Posts: 5519
Joined: Tue Apr 25, 2000 6:56 pm

TSQL Scripts

Post by mark »

Standard sql comments are double dash:
--

Note that using comments will prevent row output from select statements unless you use tsql -v .
tony.malandain
Posts: 57
Joined: Sat Mar 27, 2004 6:39 pm

TSQL Scripts

Post by tony.malandain »

Thanks Mark.
I'm so used to MS SQL that I didn't even know the double dash was the standard.

One more question about my script: I'm trying to set a foreign key reference between 2 tables.
I have
CREATE TABLE A
(
fieldA
CHAR(40)
NOT NULL
PRIMARY KEY
);

CREATE TABLE B
(
fieldB
INTEGER
NOT NULL,
refA
CHAR(40)
NOT NULL
REFERENCES A(fieldA)
);
But if I execute:
insert into B values (4, 'xxx');
an entry gets created where I was expecting Texis to throw an error because of the Foreign key constraint.
What am I doing wrong?

Thanks,
/Tony.
User avatar
John
Site Admin
Posts: 2622
Joined: Mon Apr 24, 2000 3:18 pm
Location: Cleveland, OH
Contact:

TSQL Scripts

Post by John »

Texis does not support constraints, which is why no error was generated.
John Turnbull
Thunderstone Software
tony.malandain
Posts: 57
Joined: Sat Mar 27, 2004 6:39 pm

TSQL Scripts

Post by tony.malandain »

Thanks John,

Any idea of what I could do instead? Trigger? Stored Proc?
User avatar
John
Site Admin
Posts: 2622
Joined: Mon Apr 24, 2000 3:18 pm
Location: Cleveland, OH
Contact:

TSQL Scripts

Post by John »

Generally Vortex code, which will act as stored procedure.
John Turnbull
Thunderstone Software
Post Reply