我正在尝试从 nvarchar 转换为时间,但我从 nvarchar 转换为日期和/或时间失败异常。这是我的存储过程:
USE [groep2_festivals]
GO
/****** Object: StoredProcedure [dbo].[AddBandFestival] Script Date: 15-05-13 2:52:38 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: Robbie Vercammen
-- Create date: 2013-05-14
-- Description: Inserts a new record into the bandsperfestival table
-- =============================================
ALTER PROCEDURE [dbo].[AddBandFestival]
(
@festId int,
@bandId int,
@podId int,
@date nvarchar,
@hour nvarchar
)
AS
BEGIN
INSERT INTO bandsperfestival
(fest_id, band_id, pod_id, datum, uur)
VALUES (@festId, @bandId, @podId, @date, CONVERT(time, @hour, 108))
END
convert 函数应该可以解决问题,但事实并非如此。调试器说这个字符串被赋予了存储过程:“23:01:00”并且根据这个页面:http ://networking.ringofsaturn.com/SQL/howtoformatdatetime.php和 msdn 108 应该是正确的样式这种转换,对吧?
编辑:数据的额外信息column
是类型date
并且uur
是类型time