Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Tablockx

Author  Topic 

joelseverich
Starting Member

34 Posts

Posted - 2010-02-20 : 11:42:11
Hi.

I'm trying to do this:

procedure Lock(Table)
begin
SELECT * FROM Table (TABLOCKX)
end


but it doesn't work, can anyone help me??

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-02-20 : 11:43:41
is lock(table) name of proc? then put it with []

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-02-20 : 11:45:55
quote:
Originally posted by joelseverich

Hi.

I'm trying to do this:

procedure Lock(Table)
begin
SELECT * FROM Table (TABLOCKX)
end


but it doesn't work, can anyone help me??


Is the full code you are using?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

joelseverich
Starting Member

34 Posts

Posted - 2010-02-20 : 11:48:10
the problem is that i cannot use the table name as a variable
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-02-20 : 11:50:09
quote:
Originally posted by joelseverich

the problem is that i cannot use the table name as a variable


for that you need to use dynamic sql

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-02-20 : 11:58:09
quote:
Originally posted by joelseverich

the problem is that i cannot use the table name as a variable


Why do you want to do this?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -