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.
| Author |
Topic |
|
ramoneguru
Yak Posting Veteran
69 Posts |
Posted - 2007-07-26 : 21:02:43
|
| Here is my table/insert:DECLARE @table234 TABLE( b1 INT, b2 INT) INSERT INTO @table234 (b1)SELECT COUNT(DISTINCT PersonID) AS b1 FROM Table234View_RawDataINSERT INTO @table234 (b2)SELECT COUNT(DISTINCT PersonID) AS b2 FROM Table234View_RawData WHERE (DateLeft BETWEEN '7/1/2006'AND '6/30/2007')SELECT * FROM @table234 I get 2 rows when I do the "SELECT * FROM @table234" part and it has NULL values like this:b1 b2----------163 NULL142 NULLI need it to look like this:b1 b2----------163 142What's happening here??--Nick |
|
|
Koji Matsumura
Posting Yak Master
141 Posts |
Posted - 2007-07-26 : 22:36:50
|
| Two INSERT statemtns.You are inserting two records. |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-07-27 : 04:31:29
|
[code]INSERT @Table234 ( b1, b2 )SELECT (SELECT COUNT(DISTINCT PersonID) FROM Table234View_RawData), (SELECT COUNT(DISTINCT PersonID) FROM Table234View_RawData WHERE DateLeft BETWEEN '7/1/2006'AND '6/30/2007')[/code] E 12°55'05.25"N 56°04'39.16" |
 |
|
|
ramoneguru
Yak Posting Veteran
69 Posts |
Posted - 2007-07-27 : 15:00:35
|
| Ahhhhh yes, the classic select of a select brilliant!!!--Nick |
 |
|
|
|
|
|