CREATE PROCEDURE dbo.SaveSpeed
@TableName varchar(80) = NULL,
@Speed1 float = NULL,
@Speed2 int = NULL,
@fTime float = NULL,
@iIndex int = NULL
ASIF @TableName IS NULL or @Speed1 IS NULL or Speed2 IS NULL or fTime IS NULL or iIndex IS NULL
BEGIN
PRINT 'ERROR: You must specify a value.'
RETURN
END-- INSERT the alert value to the specified Table.
INSERT INTO [str(TableName)] VALUES (@Speed1,@Speed2,@fTime,@iIndex)RETURN
GO这个存储过程在检查语法时提示错误,请大家帮忙改一下,谢了。
@TableName varchar(80) = NULL,
@Speed1 float = NULL,
@Speed2 int = NULL,
@fTime float = NULL,
@iIndex int = NULL
ASIF @TableName IS NULL or @Speed1 IS NULL or Speed2 IS NULL or fTime IS NULL or iIndex IS NULL
BEGIN
PRINT 'ERROR: You must specify a value.'
RETURN
END-- INSERT the alert value to the specified Table.
INSERT INTO [str(TableName)] VALUES (@Speed1,@Speed2,@fTime,@iIndex)RETURN
GO这个存储过程在检查语法时提示错误,请大家帮忙改一下,谢了。
解决方案 »
- 日期2008-05-03 改为2008-5-3
- 由于机器配置过低,操作sql server2005实在太慢,现在是否有开源小工具来代替sql server2005?
- 请问:采用exec执行带返回值的动态sql语句,如何取得这个返回值?
- 一个存储过程可以有多少结果集?
- SQL2008数据库置凝求解决方法
- 原来的时间字段是Int型的,现在要改成DateTime型,SQL语句能做到吗?
- 请问sqlserver 没有有记录每一条执行过的SQL或T-SQL语句的功能???????
- sql把如何两个表数据插入到一个表中?
- 请问以下SQL执行的顺序
- 怎样安装SQL2000???
- 临时表必须要在存储过程中创建和使用吗?
- 实现ID大小交替 的SQL!!
@TableName varchar(80) = NULL,
@Speed1 float = NULL,
@Speed2 int = NULL,
@fTime float = NULL,
@iIndex int = NULL
ASIF @TableName IS NULL or @Speed1 IS NULL or Speed2 IS NULL or fTime IS NULL or iIndex IS NULL
BEGIN
PRINT 'ERROR: You must specify a value.'
RETURN
END-- INSERT the alert value to the specified Table.
declare @sql varchar(8000)
set @sql = 'insert' + @TableName + 'values ('+ cast(@Speed1 as VARCHAR(20)) +',' +cast(@Speed1 as VARCHAR(20))+','+cast(@fTime as VARCHAR(20)) +','+ cast(@iIndex as VARCHAR(20)) +')'exec(@sql)RETURN
GO
@TableName varchar(80) = NULL,
@Speed1 float = NULL,
@Speed2 int = NULL,
@fTime float = NULL,
@iIndex int = NULL
ASIF @TableName IS NULL or @Speed1 IS NULL or Speed2 IS NULL or fTime IS NULL or iIndex IS NULL
BEGIN
PRINT 'ERROR: You must specify a value.'
RETURN
END-- INSERT the alert value to the specified Table.
declare @s varchar(8000)
set @s='insert into '+@tablename+' select ' +rtrim(@Speed1)+','+rtrim(@Speed2)+','+rtrim(@fTime)+','+rtrim(@iIndex)
exec(@s)RETURN
GO
@TableName varchar(80) = NULL,
@Speed1 float = NULL,
@Speed2 int = NULL,
@fTime float = NULL,
@iIndex int = NULL
ASIF @TableName IS NULL or @Speed1 IS NULL or @Speed2 IS NULL or @fTime IS NULL or @iIndex IS NULL
BEGIN
PRINT 'ERROR: You must specify a value.'
RETURN
END-- INSERT the alert value to the specified Table.
declare @sql varchar(8000)
set @sql = 'insert ' + @TableName + 'values ('+ cast(@Speed1 as VARCHAR(20)) +',' +cast(@Speed1 as VARCHAR(20))+','+cast(@fTime as VARCHAR(20)) +','+ cast(@iIndex as VARCHAR(20)) +')'exec(@sql)RETURN
GO
@TableName varchar(80) = NULL,
@Speed1 float = NULL,
@Speed2 int = NULL,
@fTime float = NULL,
@iIndex int = NULL
ASIF @TableName IS NULL or @Speed1 IS NULL or @Speed2 IS NULL or @fTime IS NULL or @iIndex IS NULL
BEGIN
PRINT 'ERROR: You must specify a value.'
RETURN
END-- INSERT the alert value to the specified Table.
INSERT INTO [str(TableName)] VALUES (@Speed1,@Speed2,@fTime,@iIndex)RETURN
GO
@TableName varchar(80) = NULL,
@Speed1 float = NULL,
@Speed2 int = NULL,
@fTime float = NULL,
@iIndex int = NULL
ASIF @TableName IS NULL or @Speed1 IS NULL or @Speed2 IS NULL or @fTime IS NULL or @iIndex IS NULL
BEGIN
PRINT 'ERROR: You must specify a value.'
RETURN
END-- INSERT the alert value to the specified Table.
INSERT INTO [str(TableName)] VALUES (@Speed1,@Speed2,@fTime,@iIndex)RETURN
GO
-------------------------
正解,
直接用[@TableName]也不行。按ojuju10的方法也在@TableName提示错误,我的TableName是有数字存在的,提示"第 1 行: '20070905150026' 附近有语法错误。"
Create table erdgzw
(
Speed1 float,
Speed2 float,
fTime int,
iIndex int
)alter PROCEDURE dbo.SaveSpeed
@TableName varchar(80) = NULL,
@Speed1 float = NULL,
@Speed2 int = NULL,
@fTime float = NULL,
@iIndex int = NULL
ASIF @TableName IS NULL or @Speed1 IS NULL or @Speed2 IS NULL or @fTime IS NULL or @iIndex IS NULL
BEGIN
PRINT 'ERROR: You must specify a value.'
RETURN
END-- INSERT the alert value to the specified Table.
declare @sql varchar(8000)
set @sql = 'insert into ' + @TableName+ ' values ('+cast(@Speed1 as varchar(10))+',' +cast(@Speed2 as varchar(10))+','+cast(@fTime as varchar(10))+','+cast(@iIndex as varchar(10))+')'
print @sql
exec(@sql)RETURN
GO
exec dbo.SaveSpeed 'erdgzw', '11.01', '11', '11.10' ,'11'select * from erdgzw
------------------------------------------------11.01 11.0 11 11
Create table [20070905150026]
(
Speed1 float,
Speed2 float,
fTime int,
iIndex int
)
create PROCEDURE dbo.SaveSpeed
@TableName varchar(80) = NULL,
@Speed1 float = NULL,
@Speed2 int = NULL,
@fTime float = NULL,
@iIndex int = NULL
ASIF @TableName IS NULL or @Speed1 IS NULL or @Speed2 IS NULL or @fTime IS NULL or @iIndex IS NULL
BEGIN
PRINT 'ERROR: You must specify a value.'
RETURN
END-- INSERT the alert value to the specified Table.
declare @sql varchar(8000)
set @sql = 'insert into ' + @TableName+ ' values ('+cast(@Speed1 as varchar(10))+',' +cast(@Speed2 as varchar(10))+','+cast(@fTime as varchar(10))+','+cast(@iIndex as varchar(10))+')'
print @sql
exec(@sql)RETURN
GO
exec dbo.SaveSpeed '[20070905150026]', '11.01', '11', '11.10' ,'11'select * from erdgzw
执行
exec SaveAlert '[20070905150026]','136.922941277777','3000','39330.6253096065','11'结果为:
insert into [20070905150026] values (136.923,3000,39330.6,11)数据类型转换错误!
'136.922941277777'变成了136.923
怎样才能全精度保存
@TableName varchar(80) = NULL,
@Speed1 float = NULL,
@Speed2 int = NULL,
@fTime float = NULL,
@iIndex int = NULL
ASIF @TableName IS NULL or @Speed1 IS NULL or Speed2 IS NULL or fTime IS NULL or iIndex IS NULL
BEGIN
PRINT 'ERROR: You must specify a value.'
RETURN
END-- INSERT the alert value to the specified Table.
declare @s varchar(8000)
set @s='insert into '+rtrim(@tablename)+' select ' +rtrim(@Speed1)+','+rtrim(@Speed2)+','+rtrim(@fTime)+','+rtrim(@iIndex)
exec(@s)RETURN
GO
exec SaveSpeed '[20070905150026]','136.922941277777','3000','39330.6253096065','11'结果为:
insert into [20070905150026] values (136.923,3000,39330.6,11)数据类型转换错误!
'136.922941277777'变成了136.923
怎样才能全精度保存