Showing posts with label qualifying. Show all posts
Showing posts with label qualifying. Show all posts

Monday, March 12, 2012

qualifying table variables

hi all!

I am using table variables instead of creating a temp table because it seems to be faster

But now I need qualify the table variable so I can join it with another table having a field with same name of a field from the table variable. U know if I can do that?

ex: with temp table

create table #tmp... (F1...)
#tmp.f1

with table variable

declare @.temp table(...
@.table.f1 - can´t do it

the first question is if I can join the table variable with another table and how to do that qualifying the variable table, that is, putting the name of the var temp with the field, because the other table has a field with same name

thank to all and happiness for all 2004Hi all

I think I found the solution

It is not possible to qualify the talble variable because it is not part of a persistent table, so I cant assing table variables,

I saw it in

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_de-dz_66w5.asp

it is the same as in sql 2000 BOL

thanks. so I have to use a temp table to qualify it if I want to join the table. My thinking is that I can join table variables

hope it is useful to u|||Hi all!

Thanks for having the time to read it

I was wrong and found the solution.

I can join and qualify a table var, only aliasing the table as in

insert into @.table... join temp.field...
from @.vartemp temp

--

here temp is the alias of @.vartemp, so I can use this alias instead of @.vartemp when, for example, there are two fields with same name in two tables, and one is @.vartemp

Now, once solved it, my problem is with UPDATETEXT. I am updating a text field and need to qualify the @.vartable in order to update it using a pointer to the text field. Since there are not any FROM clause as above, I dont know where to qualify the @.vartable (tried qualifying in DECLARE, but cant do it there)

UPDATETEXT @.vartemp.pointer - cant use @.vartemp, need an alias, but where to give the alias?

Thanks all!

qualifying Stored Procedure with owner. Why is it important/

I've been reading some posts that indicate that it is best to invoke a
Stored Procedure with the owner name. Example
exec dbo.MyStoredProc
instead of
exec MyStoredProc
I never really understood why this makes a difference.
I would appreciate it if someone could shed some light on this
Thanks in advanceWell, what about if some user 'user1' have created a procedure which is
owned by 'user1'
If you do "Exec UserProc" you will get an error, you need to use "Exec
user1.UserProc" generally it is advisable to qualify owner name before
database objects.
Things are changed in SQL 2005 where you have to qualify schema name
instead of user name for database objects
chirag shah|||in my database all objects are owned by dbo. I have read that there is a
performance impact by not qualifying the owner of the SP (even in a case
like mine where all objects are owned by dbo)
"c_shah" <shah.chirag@.netzero.net> wrote in message
news:1142951587.510508.143150@.g10g2000cwb.googlegroups.com...
> Well, what about if some user 'user1' have created a procedure which is
> owned by 'user1'
> If you do "Exec UserProc" you will get an error, you need to use "Exec
> user1.UserProc" generally it is advisable to qualify owner name before
> database objects.
> Things are changed in SQL 2005 where you have to qualify schema name
> instead of user name for database objects
> chirag shah
>|||"TJT" <TJT@.nospam.com> wrote in message
news:u0kJDZPTGHA.4864@.TK2MSFTNGP12.phx.gbl...
> in my database all objects are owned by dbo. I have read that there is a
> performance impact by not qualifying the owner of the SP (even in a case
> like mine where all objects are owned by dbo)
>
http://support.microsoft.com/default.aspx?scid=kb;en-us;263889
David|||see
http://www.sqlservercentral.com/columnists/chedgate/worstpracticenotqualifyingobjectswiththeowner.asp
for a discussion of why objects should always be qualified.
"TJT" wrote:
> in my database all objects are owned by dbo. I have read that there is a
> performance impact by not qualifying the owner of the SP (even in a case
> like mine where all objects are owned by dbo)
>
> "c_shah" <shah.chirag@.netzero.net> wrote in message
> news:1142951587.510508.143150@.g10g2000cwb.googlegroups.com...
> > Well, what about if some user 'user1' have created a procedure which is
> > owned by 'user1'
> > If you do "Exec UserProc" you will get an error, you need to use "Exec
> > user1.UserProc" generally it is advisable to qualify owner name before
> > database objects.
> >
> > Things are changed in SQL 2005 where you have to qualify schema name
> > instead of user name for database objects
> >
> > chirag shah
> >
>
>