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
 SQL Server Development (2000)
 What is wrong here

Author  Topic 

sqlbee
Starting Member

11 Posts

Posted - 2004-02-11 : 15:10:53
declare @count int
exec ('set ''' + @count + ''' = count(*)from employee')
select @count

nr
SQLTeam MVY

12543 Posts

Posted - 2004-02-11 : 15:22:46
declare @sql nvarchar(1000)
declare @count int
select @sql = 'select @count = count(*)from employee'
exec sp_executesql @sql, N'@count int out', @count out
select @count



==========================================
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

sqlbee
Starting Member

11 Posts

Posted - 2004-02-11 : 15:41:31
thanks.
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2004-02-11 : 15:52:14
And you don't do

declare @count int
select @count = count(*)from employee

Because?



Brett

8-)
Go to Top of Page

jung1975
Aged Yak Warrior

503 Posts

Posted - 2004-02-12 : 00:38:38
Nr,
In your SQL:
declare @sql nvarchar(1000)
declare @count int
select @sql = 'select @count = count(*)from employee'
exec sp_executesql @sql, N'@count int out', @count out
select @count

What's the N' for?






Go to Top of Page

JustinBigelow
SQL Gigolo

1157 Posts

Posted - 2004-02-12 : 01:01:24
N' indicates you are using nvarchar or nchar instead of varchar and char respectively for storing Unicode data.

See Books On Line for more info.

Justin

"I want to thank you. You could've given us help, but you've given us so much more."
Go to Top of Page

theGrimm
Starting Member

4 Posts

Posted - 2004-02-13 : 02:48:18
quote:
Originally posted by X002548

And you don't do

declare @count int
select @count = count(*)from employee

Because?




Enlighten me. Please.

theGrimm
Go to Top of Page
   

- Advertisement -