December 1, 2008 at 3:27 am
Hy.
I need a temporary table that loks like this:
Col1
1
2
3
4
5
Can I create it with a select statement? I wouldn't like to use a "for"
Thanks
December 1, 2008 at 3:46 am
Insert into #table (col1)
select TOP 100 ROW_NUMBER ( ) OVER (order by sys.columns.object_id) as 'rownum'
from sys.columns ,sys.tables
"Keep Trying"
December 1, 2008 at 3:56 am
dana_turcanu1981 (12/1/2008)
Hy.I need a temporary table that loks like this:
Col1
1
2
3
4
5
Can I create it with a select statement? I wouldn't like to use a "for"
Thanks
Do you want to create a number table?
Failing to plan is Planning to fail
December 1, 2008 at 4:00 am
dana_turcanu1981 (12/1/2008)
Hy.I need a temporary table that loks like this:
Col1
1
2
3
4
5
Can I create it with a select statement? I wouldn't like to use a "for"
Thanks
This is quite quick:
SELECT IDENTITY (INT, 1, 1) AS RowID, ...
INTO #Temp
FROM #SourceTable
Alternatively, create a numbers / tally table (you know you want to): http://www.sqlservercentral.com/articles/TSQL/62867/
Cheers
ChrisM
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
December 1, 2008 at 4:13 am
Chirag (12/1/2008)
Insert into #table (col1)select TOP 100 ROW_NUMBER ( ) OVER (order by sys.columns.object_id) as 'rownum'
from sys.columns ,sys.tables
The result is that I want, but the solution "from sys.columns ,sys.tables"... very interesting π
December 2, 2008 at 1:00 am
i think i got this from some code written by Jeff Modem π
"Keep Trying"
December 29, 2008 at 6:41 am
Chirag (12/2/2008)
i think i got this from some code written by Jeff Modem π
Yes he has skills to generate the code in professional way, simply he's Code Generator!
:hehe:
December 29, 2008 at 7:33 pm
dana_turcanu1981 (12/1/2008)
Hy.I need a temporary table that loks like this:
Col1
1
2
3
4
5
Can I create it with a select statement? I wouldn't like to use a "for"
Thanks
ChrisM (above) pointed you to an article that tells not only how to do it in a very high speed manner, but also a couple of things you can do with it. I recommend you read it.
Just to wet your appetite... try this... don't blink when you run it... you'll miss it... π
--===== Create and populate the Tally table on the fly
SELECT TOP 11000 --equates to more than 30 years of dates
IDENTITY(INT,1,1) AS N
INTO dbo.Tally
FROM Master.dbo.SysColumns sc1,
Master.dbo.SysColumns sc2
Once you have that, you might as well make it permanent... it's got lot's of uses... some you cannot even imagine...
--===== Add a Primary Key to maximize performance
ALTER TABLE dbo.Tally
ADD CONSTRAINT PK_Tally_N
PRIMARY KEY CLUSTERED (N) WITH FILLFACTOR = 100
--===== Allow the general public to use it
GRANT SELECT ON dbo.Tally TO PUBLIC
--Jeff Moden
Change is inevitable... Change for the better is not.
December 29, 2008 at 7:41 pm
Chirag (12/2/2008)
i think i got this from some code written by Jeff Modem π
BeeeeeeeeeeeeBoooooooooooShshshshshshhhhhhhhhh....
π
[font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
Proactive Performance Solutions, Inc. [/font][font="Verdana"] "Performance is our middle name."[/font]
December 29, 2008 at 8:57 pm
So THAT's what the helmet does! π
--Jeff Moden
Change is inevitable... Change for the better is not.
December 29, 2008 at 9:31 pm
RBarryYoung (12/29/2008)
Chirag (12/2/2008)
i think i got this from some code written by Jeff Modem πBeeeeeeeeeeeeBoooooooooooShshshshshshhhhhhhhhh....
π
Hey, I was just wondering if he's 9600, 14400 or 19200.
Jeffrey Williams
βWe are all faced with a series of great opportunities brilliantly disguised as impossible situations.β
β Charles R. Swindoll
How to post questions to get better answers faster
Managing Transaction Logs
December 29, 2008 at 9:45 pm
Jeffrey Williams (12/29/2008)
RBarryYoung (12/29/2008)
Chirag (12/2/2008)
i think i got this from some code written by Jeff Modem πBeeeeeeeeeeeeBoooooooooooShshshshshshhhhhhhhhh....
π
Hey, I was just wondering if he's 9600, 14400 or 19200.
19.2, you know Jeff. Nothing but the fastest will do. π
[font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
Proactive Performance Solutions, Inc. [/font][font="Verdana"] "Performance is our middle name."[/font]
December 29, 2008 at 9:46 pm
Jeff Moden (12/29/2008)
So THAT's what the helmet does! π
Yep. allows me to talk to R2 units and other Modems. π
[font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
Proactive Performance Solutions, Inc. [/font][font="Verdana"] "Performance is our middle name."[/font]
Viewing 13 posts - 1 through 12 (of 12 total)
You must be logged in to reply to this topic. Login to reply