Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
nmarks
Yak Posting Veteran
53 Posts |
Posted - 2008-01-02 : 08:28:58
|
| Happy New Yea one and all!Can anyone see a problem with this code (I keep getting an error message saying "incorrect syntax near '@A'")use quotesdeclare @intA int;declare @intB int;declare @SQLString nvarchar(500);declare @ParmDefinition nvarchar(500);SET @SQLString = N'EXEC sp_maximum(@A FLOAT, @B FLOAT)';SET @ParmDefinition = N'@A FLOAT, @B FLOAT';SET @intA=1;SET @intB=2;EXECUTE sp_executesql @SQLstring , @ParmDefinition, @A = @intA, @B = @intB |
|
|
nmarks
Yak Posting Veteran
53 Posts |
Posted - 2008-01-02 : 08:31:37
|
| PS I know I've declared @intA and @intB as INTs and @A and @B are FLOATs and I corrected that too but it still won't work. |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2008-01-02 : 08:33:36
|
[code]SET @SQLString = N'EXEC sp_maximum @A, @B'[/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
nmarks
Yak Posting Veteran
53 Posts |
Posted - 2008-01-02 : 08:35:23
|
| Thanks but that doesn't work either. Same error message. |
 |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2008-01-02 : 08:35:43
|
quote: Originally posted by nmarks Happy New Yea one and all!Can anyone see a problem with this code (I keep getting an error message saying "incorrect syntax near '@A'")use quotesdeclare @intA int;declare @intB int;declare @SQLString nvarchar(500);declare @ParmDefinition nvarchar(500);SET @SQLString = N'EXEC sp_maximum(@A FLOAT, @B FLOAT)';SET @ParmDefinition = N'@A FLOAT, @B FLOAT';SET @intA=1;SET @intB=2;EXECUTE sp_executesql @SQLstring , @ParmDefinition, @A = @intA, @B = @intB
There is no need of parenthesis when calling an SP.Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
nmarks
Yak Posting Veteran
53 Posts |
Posted - 2008-01-02 : 08:38:35
|
| That's it. Much obliged to you, sir.I'm in a big rush and starting not to see detail like this. I've got to slow down!Thanks. |
 |
|
|
nmarks
Yak Posting Veteran
53 Posts |
Posted - 2008-01-02 : 09:25:41
|
| For anyone else interested this was the code that worked: DECLARE @intA float; DECLARE @intB float; DECLARE @SQLString nvarchar(500); DECLARE @ParmDefinition nvarchar(500); SET @SQLString = N'EXEC sp_maximum @A , @B'; SET @ParmDefinition = N'@A FLOAT, @B FLOAT'; SET @intA=1; SET @intB=2; EXECUTE sp_executesql @SQLstring, @ParmDefinition, @A = @intA, @B = @intB; |
 |
|
|
|
|
|
|
|