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)
 why using this?

Author  Topic 

rafeequddin_ahmed
Starting Member

23 Posts

Posted - 2006-10-03 : 04:52:58
Hi,

SET @SQL4 = N'EXECUTE ' + @nvcDatabaseName + N'.dbo.sp_executesql N''


in the line above ,dynamic query is created,but why N is used here ,
what is the use of N in the above query
Thank in advanced

Kristen
Test

22859 Posts

Posted - 2006-10-03 : 04:59:03
N'MyString' means that the MyString is in UniCode, rather than normal 8-bit ASCII

Kristen
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-10-03 : 09:34:23
Why do you pass Database name as object?
Read more about Dynamic SQL

http://www.sommarskog.se/dynamic_sql.html


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2006-10-03 : 10:34:02
Actaully Madhi: isn't sp_executesql ONLY in master?

Kristen
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-10-03 : 11:39:03
quote:
Originally posted by Kristen

Actaully Madhi: isn't sp_executesql ONLY in master?

Kristen


Yes it is

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2006-10-03 : 12:56:53
But that's the beauty of sp_executesql. See what it does when you specify DBName.dbo.sp_executesql. It comes in handy for DBA scripts.

Tara Kizer
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2006-10-03 : 14:05:16
Ha! Would never have thought of that ...

Kristen
Go to Top of Page
   

- Advertisement -