Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Returning empty records. How ? 2

Status
Not open for further replies.

Deadline

Programmer
Feb 28, 2001
367
US
Hi,
Here is an unusual requirement for a query.

We'll be provided with a number, say for instance, 10. Our query is expected to return 10 empty records. No Tables, No procedures, No functions. Just a simple query should do this.

Question is, How ? Can you help me in figuring out this ? Thank you,
RR.
__________________________________
The best is yet to come.
 
Not knowing what you mean by 10 empty records, you could try this:

declare @x integer
set @x = 1
while @x < 11
begin
select null
select @x = @x + 1
end

Hope this helps.
 
I'd do it this way in SQL 2000.

Create Procedure spReturnNEmptyRows
@rowcnt int=10 As

Declare @tbl Table(<column list>)

Set nocount on --inhibit rows affected messages

--fill table
While @rowcnt > 0
Begin
Insert @tbl
Values (<empty strings, zeros or nulls>)
Set @rowcnt=@rowcnt-1
End

--select from table
Select * From @tbl
Go

If you are using an earlier version of SQL Server, create a temp table instead of using a table variable. If you want to get the best answer for your question read faq183-874.

Terry L. Broadbent - DBA
SQL Server Page:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top