Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 FOREIGN_KEY_CHECKS in MSSQL needed

Author  Topic 

micnie_2020
Posting Yak Master

232 Posts

Posted - 2010-12-08 : 22:12:08
Dear All,

Warmest Regards.

Below is mysqlcode, could anyone tell me how to write in mssql code??

1) ALTER TABLE LibraryService
SET FOREIGN_KEY_CHECKS=1


2) CREATE TABLE `LibraryBook` (
`libraryID` int(10) unsigned NOT NULL,
`bookISBN` varchar(22) NOT NULL,
`location` varchar(80) NOT NULL,
PRIMARY KEY (`libraryID`,`bookISBN`),
KEY `bookISBN` (`bookISBN`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;


Thank you.

Regards,
Micheale

GilaMonster
Master Smack Fu Yak Hacker

4507 Posts

Posted - 2010-12-09 : 00:37:15
Homework?

Open up SQL Server Books Online (the included help file) and look up ALTER TABLE and CREATE TABLE.

SQL doesn't have the option to disable foreign key checks per table. You can drop or disable a constraint, but not disable just the checks.

--
Gail Shaw
SQL Server MVP
Go to Top of Page

micnie_2020
Posting Yak Master

232 Posts

Posted - 2010-12-09 : 00:50:18
Thank you for the reply.

For create table, I stuck only at 1 command Create .... Key bookISBN(bookISBN).
The rest all i able to do.

At MS SQL it's show me error if i do Key bookISBN(bookISBN).

Any idea on this?

Thank you.

Regards,
Micheale
Go to Top of Page

GilaMonster
Master Smack Fu Yak Hacker

4507 Posts

Posted - 2010-12-09 : 11:42:21
Yes, because that's the wrong syntax. Did you look up the create table syntax as I suggested? Specifically at how you specify foreign keys?

--
Gail Shaw
SQL Server MVP
Go to Top of Page
   

- Advertisement -