【发布时间】:2016-08-07 04:40:59
【问题描述】:
我的存储过程是
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[Customer_Registrations]
@type varchar(50) = null,
@Customer_ID int = null,
@Customer_Name varchar(50) = null,
@Email varchar(50) = null,
@Password varchar(50) = null,
@Mobile varchar(50) = null
AS
BEGIN
SET NOCOUNT ON;
IF @type = 'select'
BEGIN
SELECT *
FROM ssshub..Customer_Master
END
IF @type = 'specific'
BEGIN
SELECT *
FROM ssshub..Customer_Master
WHERE Customer_ID = @Customer_ID
END
IF @type = 'insert'
BEGIN
INSERT INTO [dbo].[Customer_Master]([Customer_Name], [Email],[Password], [Mobile], [SDate])
VALUES ('@Customer_Name', '@Email', '@Password', '@Mobile', CURRENT_TIMESTAMP)
END
END
还有我的桌子
一切正常
这个查询工作正常,但是当我尝试使用存储过程插入它时,它会引发错误。
我对@987654323@ 有一个identity 规范,因此无需插入它
INSERT INTO [dbo].[Customer_Master] ([Customer_Name], [Email], [Password], [Mobile], [SDate])
VALUES('ewcewc', 'dewdw@dwc.com', 'dewdwd', '9999999999', CURRENT_TIMESTAMP)
现在当我尝试使用以下语句执行我的存储过程时
exec customer_registrations 'insert', 'dsad', 'test@test.com', 'pass', '9999900000'
我明白了:
将数据类型 varchar 转换为 int 时出错
【问题讨论】:
-
问题出在 Customer_name 列
标签: sql sql-server stored-procedures