Newbie help with syntax

Newbie help with syntax

Post by Reza Razavipou » Sun, 07 Nov 1999 04:00:00



Can somebody explain what this next statement is doing?

if exists (select * from sysobjects where id =
object_id(N'[dbo].[CLCHARGE]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[CLCHARGE]
GO

More specifically, what does the N do?

Regards

 
 
 

Newbie help with syntax

Post by Kalen Delane » Sun, 07 Nov 1999 04:00:00


N'string' indicates that the string is Unicode data. Please read about
Unicode in Books Online, and the datatypes nchar and nvarchar.

The code is just checking to see if a particular table exists before issuing
the drop command. Table names and property names are stored as Unicode
characters, so they use the N.

HTH
--
------------------------------------
Kalen Delaney
MCSE, SQL Server MCT, MVP
www.InsideSQLServer.com

Feed Someone for Free Today:
     www.TheHungerSite.com


Quote:> Can somebody explain what this next statement is doing?

> if exists (select * from sysobjects where id =
> object_id(N'[dbo].[CLCHARGE]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
> drop table [dbo].[CLCHARGE]
> GO

> More specifically, what does the N do?

> Regards


 
 
 

Newbie help with syntax

Post by Danny Ravi » Sun, 07 Nov 1999 04:00:00


this syntax is checking for the existance of table CLCHARGE in your
db and drops it if it exists ,the  N' stands for unicode represnatation of
the string
becuase all system tables hold there data in unicode.

Danny Ravid VB MVP
Tadiran Information Systems

"It's One Small Step For Man ,One Giant Leap For Mankind....."
Neil Armstrong


Quote:> Can somebody explain what this next statement is doing?

> if exists (select * from sysobjects where id =
> object_id(N'[dbo].[CLCHARGE]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
> drop table [dbo].[CLCHARGE]
> GO

> More specifically, what does the N do?

> Regards

 
 
 

Newbie help with syntax

Post by BPMargoli » Sun, 07 Nov 1999 04:00:00


Reza,

Just a minor addition. The N, if I'm not mistaken, is the ANSI SQL standard
way to indicate Unicode, not just some peculiar invention from Microsoft.


Quote:> Can somebody explain what this next statement is doing?

> if exists (select * from sysobjects where id =
> object_id(N'[dbo].[CLCHARGE]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
> drop table [dbo].[CLCHARGE]
> GO

> More specifically, what does the N do?

> Regards

 
 
 

Newbie help with syntax

Post by Umachandar Jayachandra » Mon, 08 Nov 1999 04:00:00


    Added to BP's point. Unicode strings are called NATIONAL CHARACTER
strings in ANSI SQL standards. Hence the N for representing unicode strings,
nchar, nvarchar & ntext.

--
Umachandar Jayachandran
MCDBA, MCSE + Internet, MCP + Internet, MCSE

 
 
 

1. Help Newbie dying with SP syntax

I need to create a stored procedure that calls the sp_password
stored procedure.  My syntax which generates an Error 156 is:



        select x=1
ELSE
        select x=0

I am sure you are all wondering why I am trying to this?  Well in
Access the only way to get a return value from a stored procedure
is to make it return a recordset.  In this case I will get a
recordset back in Access with one field 'x' which will have
a value of either 1 for success or 0 for failure.

Any help would be appreciated..

Thanks

Tom

2. Progress Developers Needed Now

3. Newbie Needs Help with SQL Syntax

4. Cascade ON Delete constraint

5. Syntax Help for SQL Newbie

6. BOOKS ABOUT INFORMIX

7. Newbie to Triggers - Syntax Help

8. Newbie questions...

9. Newbie: Help on trigger syntax needed.

10. Newbie package/procedure syntax help

11. SQL Syntax Help - Incorrect syntax near '%'.

12. Newbie stored proc syntax question

13. NEWBIE: easy syntax question with UPDATE statement