Xtreme Visual Basic Talk

Xtreme Visual Basic Talk (http://www.xtremevbtalk.com/)
-   .NET Database and Reporting (http://www.xtremevbtalk.com/-net-database-and-reporting/)
-   -   create table with create procedure (http://www.xtremevbtalk.com/-net-database-and-reporting/327711-create-table-create-procedure.html)

pschulz 07-27-2015 01:04 PM

create table with create procedure
Hi there,

is there no way to create a table with a create procedure command?
(ADO:NET VS 2010 SQL-Server 2008R)
otherwise I have to create a table first and then a stored procedure with an insert, thats possible, for whatever reason


PlausiblyDamp 07-28-2015 04:00 AM

Are you trying to create a stored procedure that can can create a table or are you trying to create a single script that can do both?

There shouldn't be any problem with creating a procedure to create a table so I am assuming the later.

Certain commands can't be in the same batch, typically these include things like CREATE PROC - you would need to separate them with the GO keyword. e.g.



CREATE Table ...

pschulz 08-10-2015 07:32 PM

but 'GO' doesnt work with executenonquery, or do I miss somtheing?

PlausiblyDamp 08-11-2015 09:07 AM

I am afraid not, if you are trying to do this from a stored proc or some dynamic SQL then it will need to be two separate commands.

pschulz 08-11-2015 02:25 PM

its enough to seperate them?
If I have to create two databases within one methode, i get an error, whenver the stored procedure for the second db shall be createtd
Except I let create the databases with a simple statement like:
strSQL = "CREATE DATABASE " + strDBname
instead of
strSQL = "exec ('CREATE DATABASE ' + @databaseName)"

Have expect it runs better with exec, but it does not.


All times are GMT -6. The time now is 08:45 AM.

Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2018, vBulletin Solutions, Inc.
Search Engine Optimisation provided by DragonByte SEO v2.0.15 (Lite) - vBulletin Mods & Addons Copyright © 2018 DragonByte Technologies Ltd.
All site content is protected by the Digital Millenium Act of 1998. Copyright©2001-2011 MAS Media Inc. and Extreme Visual Basic Forum. All rights reserved.
You may not copy or reproduce any portion of this site without written consent.