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 2000 Forums
 Transact-SQL (2000)
 Help createing a Transact SQL Insert Statement

Author  Topic 

malhyp
Starting Member

21 Posts

Posted - 2006-06-03 : 05:30:47
Hi there can anyone help me to create a SQL Insert Statement. I dont know SQL at all.

To explain, I have two web pages. search.asp and results.asp.

search.asp has the following.

Form Name: searchForm
Set to: Post
Action: results.asp
Text Field: Keyword
Drop Down: CategoryTable
Drop Down: Location
UserName Session Variable: MM_UserName

results.asp has the following SQL which pulls all the results.

SELECT SupplierName, Location, ShortDescription, TimberSpecies, CategoryTitle, Country, CustomerType
FROM Query1
WHERE TimberSpecies LIKE '%MMColParam%' AND CategoryTitle LIKE '%MMColParam2%' AND Location LIKE '%MMColParam3%' AND CustomerType = 'Trade/Retail'
ORDER BY CategoryTitle, TimberSpecies ASC

The database & form I want to insert into.

tblSearcheResults
idSearch (AutoNumber)
location (Text) "Want to insert the 'Location' result here"
category (Text) "Want to insert the 'CategoryTable' result here"
user (Text) "Want to insert the UserName Session Variable result here"
result (Text) "Want to insert the 'Keyword' result here"

Please ask if u need more info.

Mally

chiragkhabaria
Master Smack Fu Yak Hacker

1907 Posts

Posted - 2006-06-03 : 05:44:13
Look for Insert Clause in Book online i.e. Microsoft SQL Server help file.

It would be better if you create the stored procedure and
pass this parameters to that procedure.

Somthing like this

Create Proc Sp_InsTblSearch
(
@location varchar(8000)
@category varchar(8000)
@user varchar(8000)
@result varchar(8000)
)
As
Begin
-- This is the on approach for inserting
Insert TblSearch
Select @location,@category,@user,@result
-- Or you can use this approach for inserting

/*Insert TblSearch (location,category,user,result)
Values
(@location,@category,@user,@result)*/

End



Then call this procedure from the front end, using the
command object.

Chirag
Go to Top of Page

RyanRandall
Master Smack Fu Yak Hacker

1074 Posts

Posted - 2006-06-05 : 08:09:45
malhyp - These are good sites for learning SQL...

http://www.sql-tutorial.net/
http://www.firstsql.com/tutor.htm
http://www.w3schools.com/sql/default.asp



Ryan Randall
www.monsoonmalabar.com London-based IT consultancy

Solutions are easy. Understanding the problem, now, that's the hard part.
Go to Top of Page
   

- Advertisement -