Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

two small inserts in one query help 1

Status
Not open for further replies.

PTmon

IS-IT--Management
Mar 8, 2001
284
US
Hi, I'm trying to insert some text into one table, and an image name into a second table, with a foreign key of the first table. What I have goes through query analyzer with no errors, but never does the second insert. This is part of a web app and I've replaced the variables so it is easier to see what is happening.

Code:
Declare @intFK int
INSERT INTO tblArticles(dtmEntered,dtPublication,strArticleTitle,txtArticle)
VALUES({ts '2005-08-15 12:00:00'},convert(datetime,'8/05/2005'),'Title here','text goes here')
SET @intFK = Scope_Identity()
INSERT INTO tblImages(intArticleIDFK,strImageName,intSortOrder)
VALUES(@intFK,'image.jpg',1)

Thanks in advance!
pt

putting the "new" in "newb".....
 
What is the error that you get in query analyzer? I do not see a problem with the second insert.

Regards,
AA
 
uh...the problem was IFOS. (in FRONT of screen.) I neglected to make the intID field an identity. Sigh.
Thanks for looking.
pt

putting the "new" in "newb".....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top