DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2006
    Posts
    11

    CREATE TABLE problem!! help :S

    ok so i can create a command where it inserts a table in to my connection string using the following sql command:

    "CREATE TABLE myTable" KEY,"

    but what i want to do is not have a static table but so it changes and sets the table name to whatever is in the SQL parameter or variable.. here are a few ways i have tried:

    "CREATE TABLE @sqlParameter"
    "CREATE TABLE (@sqlParameter)"
    "CREATE TABLE " + @sqlParameter
    "CREATE TABLE " & @sqlParameter

    now do i have to do this in a stored procedure or what? can some one please point me in the right direction

  2. #2
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    Assuming you're using SQL Server, you may use the EXEC statement to execute SQL code in a string. See http://www.sqlteam.com/item.asp?ItemID=4619 for more information.

    If the parameter value is coming from the UI, you should not use dynamic SQL; it makes you vulnerable to SQL injection attacks.
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  3. #3
    Join Date
    Aug 2006
    Posts
    11
    thank you! your help is very much apreicated.. i am very new to Sql server

    cheers

Similar Threads

  1. Getting a GUI to run
    By Eric in forum Java
    Replies: 4
    Last Post: 04-14-2006, 09:09 AM
  2. Attn: Daniel Reber
    By joe in forum Database
    Replies: 0
    Last Post: 04-04-2003, 05:25 PM
  3. Re: (No subject)
    By Joe in forum Database
    Replies: 0
    Last Post: 04-04-2003, 05:13 PM
  4. Blocking problem with DSN-less connection
    By Adam Dawes in forum VB Classic
    Replies: 3
    Last Post: 12-21-2000, 11:50 AM
  5. Multi-row calculations
    By Bob Hines in forum Database
    Replies: 7
    Last Post: 04-27-2000, 11:14 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links