Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3951336
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T01:43:09+00:00 2026-05-20T01:43:09+00:00

That was a long Title but it says it all. I’m trying to make

  • 0

That was a long Title but it says it all. I’m trying to make a procedure which creates a table. I want it to be possible to choose the name of the table by writing it in the parameter. I’ve cut down on some of my code so you can see my problem.

I got so far, but it doesn’t work – any ideas?

go 
create proc newUser 
@username varchar 
as

execute 'create table '@username'(
id int,
name varchar
)'
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T01:43:10+00:00Added an answer on May 20, 2026 at 1:43 am

    This code does the job using quotename to avoid SQL injection:

    CREATE PROCEDURE newUser  
      @username NVARCHAR(1000) 
    AS  
    
    DECLARE @cmd NVARCHAR(1000)
    SET @cmd=N'CREATE TABLE '+quotename(@username)+N'(id INT, name NVARCHAR(1000))';
    EXEC (@cmd);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Kind of a long title, but that is generally the question. I want to
The title, while long, pretty much says it all. What I have is a
So that's a long title, here's what I'm doing: To avoid having report parameters
library(ggplot2) my_title = This is a really long title of a plot that I
I need to make a program that adds long integers without using the biginteger
Whew, that was a long title. Here's my problem. I've got a template class
Sorry for the long title, but it seems most descriptive for my question. Basically,
The title basically says it all. In my case, I have a polyline and
Sorry for the very long title but it's exactly what I'm looking for. I
Sorry for the long title but couldn't think of a good way to put

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.