SmashAndGrab
asked on
Help with SQL syntax please..
You need to declare variable @code and store the Code on it. I'm guessing is INT but if not then change to the correct data type:
DECLARE @Code INT
SELECT @Code = Code
FROM FF_TALLY_TABLE
WHERE Optio_Concat IS NULL
EXEC sp_name @Code
move that code to a new procedure and then just call that new procedure
ASKER
Thanks guys.
So, I've taken your advice and created another stored procedure.
Referenced it here..
Now the bit I am not sure about..
The query could bring back more than 1 record, so I need to execute the stored procedure (EXEC Optio_Concat @Code), potentially, multiple times.
Hope I've made sense.
So, I've taken your advice and created another stored procedure.
Referenced it here..
Now the bit I am not sure about..
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
Alter PROCEDURE [dbo].[FF_spOptio_Concat_Checker]
AS
BEGIN
DECLARE @Code int
Select Code FROM FF_TALLY_TABLE WHERE(Optio_Concat IS NULL)
//Now execute the original stored procedure
EXEC Optio_Concat @Code
END
The query could bring back more than 1 record, so I need to execute the stored procedure (EXEC Optio_Concat @Code), potentially, multiple times.
Hope I've made sense.
use google: transact sql loop through records
you'll probably follow this item:
https://support.microsoft.com/en-us/kb/111401
you'll probably follow this item:
https://support.microsoft.com/en-us/kb/111401
ASKER
I found this..
Thought it had worked and it didn't :(
Thought it had worked and it didn't :(
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
Alter PROCEDURE [dbo].[FF_spOptio_Concat_Checker]
AS
BEGIN
DECLARE @Code int
DECLARE db_cursor CURSOR FOR Select Code FROM FF_TALLY_TABLE WHERE(Optio_Concat IS NULL)
OPEN db_cursor
FETCH NEXT FROM db_cursor INTO @Code
WHILE @@FETCH_STATUS = 0
BEGIN
EXEC Optio_Concat @Code
END
CLOSE db_cursor
DEALLOCATE db_cursor
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
hope this give you some idea to do it.