gojohnnygogogogo
Programmer
hello,
I have created an sp to insert a record, but how do I only insert records if they don't exist in the database. ?
CREATE PROCEDURE [sp_InsertLog]
@username varchar(50),
@link varchar(100),
@Param1 varchar(50),
@Param2 varchar(50),
@SearchType varchar(50)
AS
INSERT INTO tblLogs(Username, DateAdded, Link, Param1, Param2, SearchType)
Values (@username, GetDate(), @link, @Param1, @Param2, @SearchType)
GO
so
IF username <> @username AND Param1 <> @param1 AND Param2 <> @Param2 AND SearchType<> @SearchType THEN
run sp.
ELSE
don't run sp.
I think thats thew way to do it, but I don't know how to tpye it into an sp so that it will work.
cheers all.
I have created an sp to insert a record, but how do I only insert records if they don't exist in the database. ?
CREATE PROCEDURE [sp_InsertLog]
@username varchar(50),
@link varchar(100),
@Param1 varchar(50),
@Param2 varchar(50),
@SearchType varchar(50)
AS
INSERT INTO tblLogs(Username, DateAdded, Link, Param1, Param2, SearchType)
Values (@username, GetDate(), @link, @Param1, @Param2, @SearchType)
GO
so
IF username <> @username AND Param1 <> @param1 AND Param2 <> @Param2 AND SearchType<> @SearchType THEN
run sp.
ELSE
don't run sp.
I think thats thew way to do it, but I don't know how to tpye it into an sp so that it will work.
cheers all.