Using variables in 'create database'

Using variables in 'create database'

Post by Steve Ros » Sat, 02 Jul 1994 21:41:57



The System 10 manual for variables says that they can only be used where
constants are allowed in SQL statements.

Why does the following yield an error then:




4> go
Message from SQL server MCS_MED_SVR (msg 102, level 15, state 1):

--
--------------------------------
     Steve Rosen
     Fox Chase Cancer Center

      (215) 728-3665
________________________________

 
 
 

1. Local variables and 'Create Table'

OK, I've stared at this long enough.  Maybe someone else can see what
I'm doing wrong.  I have a batch (eventually to be a stored procedure)
which creates a temporary table which will be used later to populate
several permanent tables.  I need to be able to set the seed of the
identity column depending on the contents of some other table.  Here's
an excerpt which shows the problem:

------------------------------
SET NOCOUNT ON


ecomm_address_data

Create Table #temp_addr_data (

        [shopper_id] [char] (32) NOT NULL
)

Insert Into #temp_addr_data ( shopper_id )
SELECT ecomm_shopper.shopper_id FROM ecomm_shopper

select * from #temp_addr_data

SET NOCOUNT OFF
------------------------------


may be 1 if the table ecomm_address_data is empty, or some positive
value (say, 12345) if it's not; I can print those out so I know they're
correct.


If I change this line, inserting an explicit value, so it reads
"IDENTITY (12345, 1)" it will correctly create and load the table
starting with AddressDataID=12345.  How do I get this to work with the
local variable so I can read the correct value from the external table?

Sent via Deja.com http://www.deja.com/
Before you buy.

2. Could you help me with Recordset Problems?

3. Using variables in the 'CONTAINS' predicate

4. FoxPro 2.6/Mac latest version? 2.6a ?

5. using variables in the 'WHERE' clause

6. tables and db's

7. Using N'str' with variables

8. creating procedure - ver 3

9. Passing a 'variable' Variable

10. Variable 'variable' names in Opal

11. Database trigger: bad bind variable 'NEW'

12. Database trigger : bad bind variable 'NEW'

13. Error creating linked server using 'MSIDXS'