January 2, 2018 at 7:19 pm
CREATE PROCEDURE sp_cenik
as begin
DECLARE
@OD DATETIME,
@DO DATETIME,
@TipSobe VARCHAR(6),
@KodaCenika INT,
@Sezona INT
SELECT
@Od = :a2,
@Do = :a3,
@TipSobe = :a1,
@KodaCenika = :a4;
I get:
"Msg 102, Level 15, State 1, Procedure sp_cenik, Line 18
Incorrect syntax near ':'.
What am I doing wrong ? These are parameters.
January 2, 2018 at 7:39 pm
Senchi - Tuesday, January 2, 2018 7:19 PMCREATE PROCEDURE sp_cenik
as beginDECLARE
@OD DATETIME,
@DO DATETIME,
@TipSobe VARCHAR(6),
@KodaCenika INT,
@Sezona INTSELECT
@Od = :a2,
@Do = :a3,
@TipSobe = :a1,
@KodaCenika = :a4;I get:
"Msg 102, Level 15, State 1, Procedure sp_cenik, Line 18
Incorrect syntax near ':'.What am I doing wrong ? These are parameters.
If they are, in fact, parameters as you say, then that's the wrong way to pass parameters in a stored procedure. Please see the following...
https://docs.microsoft.com/en-us/sql/t-sql/statements/create-procedure-transact-sql
Parameters look like variables that begin with @.
--Jeff Moden
Change is inevitable... Change for the better is not.
January 2, 2018 at 8:02 pm
DECLARE
@OD DATETIME,
@DO DATETIME,
@TipSobe VARCHAR(6),
@KodaCenika INT,
@Sezona INT,
@p1 DATETIME,
@p2 DATETIME,
@p3 VARCHAR(6),
@p4 INT
SELECT
@Od = @p1, @Do = @p2, @TipSobe =@p3, @KodaCenika = @p4
so this would be the way to go ...?
January 2, 2018 at 8:46 pm
Could you explain what this does? (Is this Oracle?)SELECT
@Od = :a2,
@Do = :a3,
@TipSobe = :a1,
@KodaCenika = :a4;
January 2, 2018 at 9:03 pm
this is sql server 2014 and those are parameters I supply within my application.
January 3, 2018 at 12:27 am
No, that's declaring variables. (and no idea what the unknown language is doing)
Please have a look at the T-SQL documentation for creating procedures: https://docs.microsoft.com/en-us/sql/t-sql/statements/create-procedure-transact-sql
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
January 3, 2018 at 4:41 am
Senchi - Tuesday, January 2, 2018 7:19 PMCREATE PROCEDURE sp_cenik
as beginDECLARE
@OD DATETIME,
@DO DATETIME,
@TipSobe VARCHAR(6),
@KodaCenika INT,
@Sezona INTSELECT
@Od = :a2,
@Do = :a3,
@TipSobe = :a1,
@KodaCenika = :a4;I get:
"Msg 102, Level 15, State 1, Procedure sp_cenik, Line 18
Incorrect syntax near ':'.What am I doing wrong ? These are parameters.
So, the error message says that your syntax is messed up at the colon, this thing, : . You have colons on your code. T-SQL doesn't use colons in syntax like that. This is why everyone is having a hard time helping.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply