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: Yesterday @ 2:45 PM
Points: 382, Visits: 1,229
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


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Today @ 2:31 PM
Points: 2,804, Visits: 6,155
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, February 4, 2015 2:43 AM
Points: 2,953, Visits: 440
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: Today @ 2:00 AM
Points: 2,854, Visits: 2,729
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: Thursday, June 18, 2015 4:22 AM
Points: 1,274, Visits: 1,990
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: Tuesday, June 16, 2015 9:02 AM
Points: 1,096, Visits: 2,633
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: Today @ 3:27 PM
Points: 32,135, Visits: 16,533
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: Friday, June 26, 2015 11:10 AM
Points: 3,224, Visits: 2,399
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