on 2010 Sep 14 9:07 PM
This code works great in ISQL... version 9.0.2
INPUT into mytable (..., ....) from myfile format ascii;
But this code doesn't work at all...
BEGIN
declare @starttime timestamp;
set @starttime =current timestamp;
INPUT into mytable (..., ....) from myfile format ascii;
-- more stuff goes here
END
The error is Syntax error near INSERT
I understand that the INSERT statement is handled by the ISQL client and not the server, but I think I need the BEGIN/END to contain the declared variables.
Any way around this?
Request clarification before answering.
You could use CREATE VARIABLE to define the variables. However, they will not be dropped automatically at the end of the script, so you would need to add corresponding DROP VARIABLE statements. Also, you might want to handle the case where the script is interrupted before completion and then re-executed using the same connection. To do so, add:
if varexists('@starttime') = 0 then
create variable @starttime timestamp;
end if;
Version 12 adds CREATE OR REPLACE VARIABLE.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
31 | |
9 | |
8 | |
6 | |
6 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.