September 26, 2002 at 3:40 pm
tblJunk has one record and looks like:
(a,b)
I’m trying to retrieve those values into local variables using SELECT INTO:
select c1, c2 into :v1, :v2 from tblJunk
When I execute it I get “Line 1: Incorrect syntax near ':'.” I saw this syntax in BOL: “SELECT INTO” > “SELECT INTO” but I can’t make it work. Help!
TIA,
Bill
September 26, 2002 at 3:51 pm
Since youre table only contains one records this will work:
Declare @V1 <datatype for a, in table TblJunk)
Declare @V2 <database for b, in table TblJunk>
Select @v1 = a, @v2 = b from TblJunk
Now if you have multiple records in TblJunk, you will then need to select each record individually to do this. Then I would use a cursor, or a very, very, selective SELECT statement (one that would return only one row). But thats another discussion.
Gregory Larsen, DBA
If you looking for SQL Server Examples check out my website at http://www.geocities.com/sqlserverexamples
Gregory A. Larsen, MVP
September 27, 2002 at 6:45 am
The colon (:) with a variable (:v1) identifies a 'host variable'. A host variable is a C-program variable. See the Books Online, go to index and look for 'host variables' then select the 'using host variables' option.
-Bill
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply