Re: Creating temp tables in MSSQL

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux