Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase 12»»

TSQL Expand / Collapse
Author
Message
Posted Saturday, February 7, 2009 11:24 AM


Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Friday, June 6, 2014 4:17 PM
Points: 382, Visits: 1,141
Comments posted to this topic are about the item TSQL

Sankar Reddy | http://SankarReddy.com/
Post #652261
Posted Saturday, February 7, 2009 11:26 AM


Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Yesterday @ 3:29 PM
Points: 3,983, Visits: 6,015
I've been using INSERT INTO for so long that I forgot INTO was optional. Who knew?

__________________________________________________

Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? -- Stephen Stills
Post #652263
Posted Sunday, February 8, 2009 4:01 PM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Wednesday, June 25, 2014 9:26 PM
Points: 2,953, Visits: 436
Whilst I totally understand it's a valid identifier, I just want to understand, does that query create a table with the name "#", or does it create a temporary table with no name?


Urbis, an urban transformation company
Post #652486
Posted Monday, February 9, 2009 1:01 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Yesterday @ 12:53 AM
Points: 2,450, Visits: 2,340
Iggy (2/8/2009)
Whilst I totally understand it's a valid identifier, I just want to understand, does that query create a table with the name "#", or does it create a temporary table with no name?

Create a temporary table with name #.
Post #652577
Posted Monday, February 9, 2009 4:31 AM


UDP Broadcaster

UDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP Broadcaster

Group: General Forum Members
Last Login: Wednesday, January 2, 2013 12:15 PM
Points: 1,443, Visits: 711
It's a cool bit of trivia that it works, but not good programming practice- better to name the table something meaningful!

Reminds me of some code I inherited code that used a b and c etc as variable names.... tough to maintain and bad programming practice...
Post #652687
Posted Monday, February 9, 2009 7:07 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Tuesday, February 18, 2014 7:14 AM
Points: 1,344, Visits: 1,983
Of course, if you want to be really silly you can do
create table # (_ int)
go
insert # select 1
go
select * from #



Derek
Post #652789
Posted Monday, February 9, 2009 8:19 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Friday, June 13, 2014 11:35 AM
Points: 1,093, Visits: 2,610
Derek Dongray (2/9/2009)
Of course, if you want to be really silly you can do
create table # (_ int)
go
insert # select 1
go
select * from #




I'll use that next time I need to interview someone




_______________________________________________________________________
For better assistance in answering your questions, click here
Post #652853
Posted Monday, February 9, 2009 8:23 AM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: Administrators
Last Login: Wednesday, June 11, 2014 5:42 PM
Points: 33,007, Visits: 15,132
It's definitely a trivia question and I wouldn't recommend coding like this as all, unless you're in some type of contest for obfuscating code.

I also wouldn't let someone use this as an identifier, but it's good to know this is an issue.







Follow me on Twitter: @way0utwest

Forum Etiquette: How to post data/code on a forum to get the best help
Post #652859
Posted Monday, February 9, 2009 9:45 AM
Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Yesterday @ 4:54 PM
Points: 3,159, Visits: 2,242
and yet another "but why" ...

create table [table] ([int] int)
go
insert [table] select 1
go
select [int] from [table]
go




Regards
Rudy Komacsar
Senior Database Administrator

"Ave Caesar! - Morituri te salutamus."
Post #652958
Posted Monday, February 9, 2009 9:58 AM
SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Tuesday, December 7, 2010 8:13 AM
Points: 436, Visits: 322
So it adds a temp table into memory or on the permamnent media or both? How long does the temp table last?

There have been times when I want to use a temp table to hold some data for the length of a webpage, but I generally have a table called tempSomethingMeaningful and clear the table when I am done. This way I don't have to worry about setting up the columns every time.
Post #652979
« Prev Topic | Next Topic »

Add to briefcase 12»»

Permissions Expand / Collapse