I have created a stored procedure using T-SQL.
I run it using this query
EXEC insertfbusers email, name
But when testing it in SQL Server Management Studio it inserts the same row twice, which causes a Primary Key violation.
The Primary Key is on the email column.
Why does it insert two rows?
Here’s my procedure
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
GO
-- ================================
-- Created
-- by: dbo
-- on: Monday, October 08, 2012 1:10 AM
-- Description: <Description>
-- ================================
ALTER PROCEDURE dbo.insertfbusers
-- Add the parameters for the procedure here
@email varchar(100),
@firstname varchar(50)
AS
BEGIN
SET NOCOUNT ON;
-- Insert statements for procedure here
INSERT INTO t_user VALUES (@email, @firstname)
END
I got it fixed! Must have been something wierd with the online based admin I used yesterday. I ran the code today from SQL MANAGEMENT STUDIO and it worked like a charm.
Thanks for the help anyway!