x

What is the use of #?

Just wanna know, if what is the use of # symbol beside the table name PaySlip?

CREATE TABLE #PaySlip(
   WorkId int,
   PName nvarchar(max),
   Client nvarchar(max),
   PayPeriod nvarchar(max),
   PayDt nvarchar(max),
   Particulars varchar(max),
   RefInfo nvarchar(max),
      DAmt nvarchar(max),
   CAmt nvarchar(max),
   RunBal nvarchar(max),
   ToDeBit nvarchar(max),
   ToCredit nvarchar(max),
   ToPay nvarchar(max),
   AcctNo nvarchar(max),
   --
   Template nvarchar(max),
   Rate decimal(18,2)
   )
Thanks and regards.
more ▼

asked Jul 25 '12 at 01:11 AM in Default

jeff020590 gravatar image

jeff020590
1 3 3 3

(comments are locked)
10|1200 characters needed characters left

2 answers: sort voted first

This creates a temporary table which is locally scoped to the connection. This temporary table will be automatically dropped when the connection using it is terminated (or the table is explicitly dropped).

You can also have ## global temporary tables which are server scoped, thus accessible by any connection, and automatically dropped when there are no more connections using it.

Finally you can have @ table variables which are scoped to the query and not stored beyond that.
more ▼

answered Jul 25 '12 at 04:41 AM

SirSQL gravatar image

SirSQL
4.8k 1 3

(comments are locked)
10|1200 characters needed characters left
The symbol # show the object is temporary
more ▼

answered Jul 25 '12 at 01:31 PM

basit 1 gravatar image

basit 1
449 49 61 81

(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

New code box

There's a new way to format code on the site - the red speech bubble logo will automatically format T-SQL for you. The original code box is still there for XML, etc. More details here.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.

Topics:

x401
x33

asked: Jul 25 '12 at 01:11 AM

Seen: 703 times

Last Updated: Jul 25 '12 at 01:31 PM