[Date Prev][Date Next][Thread Prev][Thread Next]
[Author Index] [Date Index] [Thread Index]
[SQR-USERS Info] [SQRUG Home Page]

Re: Creating temp table in SQL Server



I have not used MS SQL Server but with Sybase (from which MS SQL Server was
spawned) the begin-program would go



begin-program
  begin-sql
    insert into #rick
    select * from srsch
  end-sql
end-program

The way you have it coded it would be trying to create a temp table that you
previously created and would get quite upset.

HTH

-----Original Message-----
From: Shaver, Richard H [mailto:richard.h.shaver@LMCO.COM]
Sent: Tuesday, October 19, 1999 09:25 AM
To: Multiple recipients of list SQR-USERS
Subject: Creating temp table in SQL Server


I can't seem to find the right syntax to create a temporary table in SQL
Server using SQR.  SQL Server builds temporary tables when the table name is
preceded by a #.  It is simple enough to do within the database using the
native language (i.e. CREATE #TEMP (FIELD TYPE), but when I try to use the
same syntax in SQR I receive the "COUNT field incorrect" error.  If I put
brackets around the table name, i.e. CREATE [#TEMP], SQR returns the
"incorrect syntax near [" error.  (I got the idea for the brackets from the
SQR Users group page, but it was in regards to Informix.)

I have tried the Create command and the Select * Into command with the same
results.


begin-program
  begin-sql
    create table #rick (test char(4))
  end-sql
end-program


begin-program
  begin-sql
    select * into [#rick] from srsch
  end-sql
end-program


The same SQR syntax creates a permanent table if I remove the # from in
front of the table name, but that sort of defeats the purpose.  Any ideas??

tia
Rick Shaver
LM Data Systems
1-360.396.8488