Have you considered just using DDL statements directly? You should be
able to execute those directly from C# via the System.Data.SqlClient
objects. It's really no different than executing INSERT/UPDATE/DELETE
statements.

For example:

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

CREATE PROCEDURE spMyProc(@Arg1 int, @Arg2 int) AS
...your statements here.....

Put all of the above into a string variable, the execute it through a
SqlCommand object. Might be a more object-oriented way to do it, but
this should work, assuming you have sufficient priviledges.


-----Original Message-----
From: dotnet discussion [mailto:[EMAIL PROTECTED]] On Behalf Of
Jeff Block
Sent: Wednesday, April 24, 2002 4:11 PM
To: [EMAIL PROTECTED]
Subject: [DOTNET] Checking Existance and Creating SqlServer Objects


Is there a way to query for the existance of tables and stored
procedures
from C#?  From VB6 land I was using SQLDMO, but can't seem to figure it
out through interop in C#.  I want to be able to create tables, but only
if they don't exist first, stored procedures I would most likely want to
just drop and recreate.  Any thoughts would be very appreciated!

TIA...

Jeff

You can read messages from the DOTNET archive, unsubscribe from DOTNET,
or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to