Showing posts with label explain. Show all posts
Showing posts with label explain. Show all posts

Wednesday, March 21, 2012

Generating Script

What does N indicate in the following script

SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].xxxx' )

Plz can anyone explain

EXEC dbo.sp_executesql @.statement = N'Create View xxxxx'

The 'N' in the likes of N'[dbo].xxxx' and N'Create View xxxxx' indicates an NVARCHAR datatype. This is the datatype that is used for representing UNICODE strings. The NVARCHAR datatype uses two bytes to represent each character whereas the VARCHAR datatype uses one byte to represent each character.

Also, if you are asking for an explanation of the statement:

Code Snippet

EXEC dbo.sp_executesql @.statement = N'Create View xxxxx'

The "sp_executesql" stored procedure is a stored procedure that is used for executing dynamically created SQL statements. In this case the dynamic SQL statement is the "CREATE VIEW ... " piece. And in this case this statement is used to create a view.

|||Thank you...i have also seen from the MSDN help that N denotes unicode strings which uses 2 bytes to represent each character|||That is correct. Nvarchar/Nchar will store UNICODE values.

Monday, March 12, 2012

Generated sprocs of VS2005

Can someone explain the generated sprocs of VS2005 if one column can be nullable

DependentOfSeqID = @.Original_DependentOfSeqID OR ((@.IsNull_DependentOfSeqID = 1) AND (DependentOfSeqID IS NULL))

In VS2003 the generated sprocs would be

DependentOfSeqID = @.Original_DependentOfSeqID OR ((@.Original_DependentOfSeqID IS NULL) AND (DependentOfSeqID IS NULL))

Which is the best?

I guess the 2 statements are the same: the first 1 uses a variable @.IsNull_DependentOfSeqID to determine whther the @.Original_DependentOfSeqID is null; while the 2nd directly compare it to null.