Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: SQL Syntax Error


Message #1 by "Christian Dygaard" <cdygaard@w...> on Fri, 22 Feb 2002 21:05:59 +0100
Hello fellow programmers



I get an error parsing this stored procedure:



CREATE PROCEDURE dbo.up_parmins_UserT_CCT

   (@Firstname VarChar(50),

    @Lastname VarChar(50),

    @EmailAddress VarChar(50),

    @Username VarChar(30),

    @Password VarChar(10),

    @CCType VarChar(20),

    @ExpMonth Int,

    @ExpYear Int,

    @CCNumber Uniqueidentifier,

    @Donations Money) AS

INSERT INTO User_T (First_Name_VC, Last_Name_VC,

Email_Address_VC, User_Name_VC, Password_VC,

Creditcard_Type_VC, Creditcard_Exp_Month_IN,

Creditcard_Exp_Year_IN, Creditcard_Number_UI,

Donations_MN) VALUES (@Firstname, @Lastname,

@EmailAddress, @Username, @Password, @CCType,

@ExpMonth, @ExpYear, @CCNumber, @Donations)

JOIN Creditcard_T ON 

Creditcard_T.Creditcard_ID = User_T.Creditcard_ID

WHERE User_Name_VC = @Username AND

Password_VC = @Password



I get the error message:



Server: Msg 156, Level 15, State 1, Procedure up_parmins_UserT_CCT, Line 19

Incorrect syntax near the keyword 'JOIN'.



What's the problem?



Thanks in advance



Regards Christian Dygaard

Message #2 by "Breidenbach, Beth" <Beth.Breidenbach@g...> on Fri, 22 Feb 2002 12:23:17 -0800
What's the purpose of the join to CreditCard_T?  Which fields come from 

it?



-----Original Message-----

From: Christian Dygaard [mailto:cdygaard@w...]

Sent: Friday, February 22, 2002 12:06 PM

To: ASP Databases

Subject: [asp_databases] SQL Syntax Error





Hello fellow programmers



I get an error parsing this stored procedure:



CREATE PROCEDURE dbo.up_parmins_UserT_CCT

   (@Firstname VarChar(50),

    @Lastname VarChar(50),

    @EmailAddress VarChar(50),

    @Username VarChar(30),

    @Password VarChar(10),

    @CCType VarChar(20),

    @ExpMonth Int,

    @ExpYear Int,

    @CCNumber Uniqueidentifier,

    @Donations Money) AS

INSERT INTO User_T (First_Name_VC, Last_Name_VC,

Email_Address_VC, User_Name_VC, Password_VC,

Creditcard_Type_VC, Creditcard_Exp_Month_IN,

Creditcard_Exp_Year_IN, Creditcard_Number_UI,

Donations_MN) VALUES (@Firstname, @Lastname,

@EmailAddress, @Username, @Password, @CCType,

@ExpMonth, @ExpYear, @CCNumber, @Donations)

JOIN Creditcard_T ON

Creditcard_T.Creditcard_ID =3D User_T.Creditcard_ID

WHERE User_Name_VC =3D @Username AND

Password_VC =3D @Password



I get the error message:



Server: Msg 156, Level 15, State 1, Procedure up_parmins_UserT_CCT, Line 

19

Incorrect syntax near the keyword 'JOIN'.



What's the problem?



Thanks in advance



Regards Christian Dygaard






$subst('Email.Unsub').

Message #3 by agaisin@c... on Fri, 22 Feb 2002 17:17:16 +0000
looks like the syntax is off.

you can insert into table1 (field1,field2...) values (value1,value2...)

or

you can insert into table1 (field1,field2) select value1,value2 from table2....

in the second type of insert statement, you can also do what you want:

insert into table1(fieldx,fieldy,fieldz) select x,y,z from tableA join tableB on .....



see 

http://www.devguru.com/Technologies/jetsql/quickref/insert_into.html

for an explanation and an example of inserting into a table using a join as you are trying to do... 

(the example is at the bottom of the page...)



hth,

Arthur Gaisin



---- Message from "Breidenbach, Beth" <Beth.Breidenbach@g...> at Fri, 22 Feb 2002 12:23:17 -0800 ------

What's the purpose of the join to CreditCard T?  Which fields come from it?



-----Original Message-----

From: Christian Dygaard [mailto:cdygaard@w...]

Sent: Friday, February 22, 2002 12:06 PM

To: ASP Databases

Subject: [asp databases] SQL Syntax Error





Hello fellow programmers



I get an error parsing this stored procedure:



CREATE PROCEDURE dbo.up parmins UserT CCT

   (@Firstname VarChar(50),

    @Lastname VarChar(50),

    @EmailAddress VarChar(50),

    @Username VarChar(30),

    @Password VarChar(10),

    @CCType VarChar(20),

    @ExpMonth Int,

    @ExpYear Int,

    @CCNumber Uniqueidentifier,

    @Donations Money) AS

INSERT INTO User T (First Name VC, Last Name VC,

Email Address VC, User Name VC, Password VC,

Creditcard Type VC, Creditcard Exp Month IN,

Creditcard Exp Year IN, Creditcard Number UI,

Donations MN) VALUES (@Firstname, @Lastname,

@EmailAddress, @Username, @Password, @CCType,

@ExpMonth, @ExpYear, @CCNumber, @Donations)

JOIN Creditcard T ON 

Creditcard T.Creditcard ID = User T.Creditcard ID

WHERE User Name VC = @Username AND

Password VC = @Password



I get the error message:



Server: Msg 156, Level 15, State 1, Procedure up parmins UserT CCT, Line 19

Incorrect syntax near the keyword 'JOIN'.



What's the problem?



Thanks in advance



Regards Christian Dygaard





to unsubscribe send a blank email to leave-asp databases-804126D@p...





to unsubscribe send a blank email to leave-asp databases-804126D@p...






  Return to Index