Re: Dynamic query to store record count in variable????
From: Andrew J. Kelly (sqlmvpnooospam_at_shadhawk.com)
Date: 12/01/04
- Next message: Richard_SQL: "RE: Question about trigger"
- Previous message: Andrew J. Kelly: "Re: My Database doesnt appear to have a transaction log!"
- In reply to: Chris: "Dynamic query to store record count in variable????"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 1 Dec 2004 13:40:49 -0500
Have a look here:
http://www.sommarskog.se/dynamic_sql.html
http://www.support.microsoft.com/?id=262499
-- Andrew J. Kelly SQL MVP "Chris" <Chris@discussions.microsoft.com> wrote in message news:292BA190-F8FD-4696-A6EA-8EE930095F5A@microsoft.com... > Hello everyone, > > I am attempting to write a stored procedure to retrieve the record count > but > have failed so far. Here's what I have tried... > > SET @value = 'SELECT COUNT(*) FROM ' + @tablea > EXECUTE sp_executesql @sql > > ...but this just ends up displaying the count to the screen, so I did.... > > SET @value = 'DECLARE @tablea_count NVARCHAR(128) SELECT > @tablea_count=COUNT(*) FROM ' + @tablea > EXECUTE sp_executesql @sql, @tablea_count OUTPUT > > but this doesnt seem to work either. > > Help??? > -- > Chris
- Next message: Richard_SQL: "RE: Question about trigger"
- Previous message: Andrew J. Kelly: "Re: My Database doesnt appear to have a transaction log!"
- In reply to: Chris: "Dynamic query to store record count in variable????"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|