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.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 is there a variant of SELECT TOP 0 that

Author  Topic 

gdeconto
Posting Yak Master

107 Posts

Posted - 2003-12-22 : 11:58:31
is there a variant of the select stmt that returns a single record that contains the default values for a given table??

ie say I have a table with two fields, one an int that defaults to 0 and one a varchar that defaults to 'asdf'

what I'd like to do is do something like:

select top x 'qwer', * from tablefoo

and get back a single record containing the following:

qwer, 0, asdf

my real tables contain many more fields than this example, of course.

what I really have is a situation where I want to return say the top n records that meet a given condition and then an additional record that contains a special indicator value.

any ideas guys/gals??

nr
SQLTeam MVY

12543 Posts

Posted - 2003-12-22 : 12:17:33
You can get the defaults for the table from sysconstraints and syscomments.

I suppose you could use a trigger to return the resultset from inserted but would need a method to know whether this was a real insert or to return the defaults.


==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -