Hi John, you need to specify a name for the column that you create with the convert function. Like this select distinct convert(varchar(36), amount) id into #temp1 from fred #temp1 will now have one column called id. #temp1 can be removed with droptable #temp1 or by closing the connection to the database. - Frank > Thanks for your response Frank, but this is still driving me nuts and > making me look like a moron at the same time (-: > > This simplified query: > $query = "SELECT distinct convert(varchar(36),a.traineeID) INTO #tempdata1"; > $query .=" FROM tblSignIn_trainee a"; > $queryresult = MSSQL_QUERY($query,$cn) or die ("Error in query: $query. > " .mssql_get_last_message()); > > does not work. > > The databases connection which I am using connects with db_datareader > rights to SQL Server - from what I understand no special rights are > needed to create a temporary table. > > Using mssql_get_last_message() gives me the message:Changed database > context to 'thedatabasenameisprintedhere'. > > What the heck is going on here? > > > > > > Frank M. Kromann wrote: > > >Hi, > > > >Any table that starts with # is a temp table. You can use > > > >create table #mytemp (...) or you should be able to use the query you > >suggest. You just have to make sure you have enough space in tempdb (a > >system database) > > > >- Frank > > > > > > > >>Hi all, > >> > >>I've been handed a query which I'm trying to get to work. I'm using PHP > >> > >> > > > > > > > >>to talk to MSSQL 7. > >> > >>My question is this: Can I create temp tables with mssql without > >>executing the code in a stored procedure? > >> > >>The simplified version of the query is as follows: > >>$query = "SELECT distinct convert(varchar(36),traineeID)"; > >>$query.=" INTO #tempdata1"; > >>$query.=" FROM tblSignIn_trainee a"; > >> > >> > >>Later on I could make a stored procedure, but at the moment I would like > >> > >> > > > > > > > >>to just work with the query directly in the code if at all possible. > >> > >>Thanks, > >>John > >> > >>-- > >>PHP Database Mailing List (http://www.php.net/) > >>To unsubscribe, visit: http://www.php.net/unsub.php > >> > >> > >> > > > > > > > > > > > > > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php