Re: Using "Table" variable

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Uri Dimant (urid_at_iscar.co.il)
Date: 11/03/04


Date: Wed, 3 Nov 2004 08:29:35 +0200

Adam
> Table variables are actually created in TEMPDB
Does not SQL Server create and manage it in the memory?

"Adam Machanic" <amachanic@hotmail._removetoemail_.com> wrote in message
news:OMSEbiQwEHA.536@TK2MSFTNGP11.phx.gbl...
> Vijay,
>
> Table variables are actually created in TEMPDB, so you will get the
> collation from that database by default. You could try to fix this by
using
> database_default instead of specifying an actual collation name:
>
>
> DECLARE @Order_Numbers_Table TABLE
> (
> [Serial] INT IDENTITY(1,1) NOT NULL PRIMARY KEY,
> [Order] CHAR(11) COLLATE database_default
> )
>
> --
> Adam Machanic
> SQL Server MVP
> http://www.sqljunkies.com/weblog/amachanic
> --
>
>
> "Vijay" <vijay@infosysusa.com> wrote in message
> news:eBp4SXQwEHA.1260@TK2MSFTNGP10.phx.gbl...
> > Hi,
> >
> > I am trying to use the "table" variable in the stored procedure as
> follows.
> >
> > DECLARE @Order_Numbers_Table TABLE
> > (
> > [Serial] INT IDENTITY(1,1) NOT NULL PRIMARY KEY,
> > [Order] CHAR(11)
> > )
> >
> > My current database and its objects are in the collation named "COLLATE
> > SQL_Latin1_General_CP1_CI_AS".
> > My SQL server and model databases are in the collation named "
> > Latin_General_BIN".
> >
> > I though that if we didn't mention the collation for [Order] column, it
> will
> > take the database collation as default.
> > But i got the error as "Cannot resolve collation conflict for equal to
> > operation.".
> >
> > It is working fine when i use explicitly collation as follows.
> > DECLARE @Order_Numbers_Table TABLE
> > (
> > [Serial] INT IDENTITY(1,1) NOT NULL PRIMARY KEY,
> > [Order] CHAR(11) COLLATE SQL_Latin1_General_CP1_CI_AS
> > )
> >
> > How can i write the generalized procs to create on any databases
> > irrespective of its collations?
> >
> > Thanks,
> > Vijay
> >
> >
>
>



Relevant Pages

  • RE: URGENT : Change TempDB collation
    ... Everytime SQL server is re-started, tempdb takes the collation from model ... Ideally changing the collation of model db should sort the problem. ... And having tempdb collation different from users database can potentially ...
    (microsoft.public.sqlserver.server)
  • Re: Is it possible to change tempdb?
    ... > Is it possible to define another database to function as the tempdb ... no, it's not possible unless you reinstall the SQL Server 2000 instance, as ... tmpdb collation is inherited from the system databases setting and is the ... you can not define an "alternative" user defined tempdb database... ...
    (microsoft.public.sqlserver.server)
  • RE: Advice on Create a SQL Server
    ... Use the default collation. ... domain, and running on a windows domain account, it is better to run under ... Windows Authentication mode. ... to SQL Server using a username/password. ...
    (microsoft.public.sqlserver.setup)
  • RE: Advice on Create a SQL Server
    ... Use the default collation. ... Mode" - it depends on how you will be connecting to your database. ... domain, and running on a windows domain account, it is better to run under ... to SQL Server using a username/password. ...
    (microsoft.public.sqlserver.setup)
  • Re: Installing SQL_Latin1_General_CP1_CI_AS collation order??
    ... Tibor Karaszi, SQL Server MVP ... "Ward Horsfall" wrote in message ... >> rebuildm.exe) interfaces and a collation designator, ...
    (microsoft.public.sqlserver.setup)