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 9088289
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T21:52:52+00:00 2026-06-16T21:52:52+00:00

here is an interesting problem in Sql Server; I have a stored procedure, that

  • 0

here is an interesting problem in Sql Server; I have a stored procedure, that returns the following error when executed:

The type ‘MyTable’ already exists, or you do not have permission to
create it.

I think the type MyTable wasn’t properly created, and I base this guess upon the fact other types (nvarchar, for example) are all coloured in blue, whereas when I hover the mouse above @T declaration (DECLARE @T AS MyTable), it says @T has an invalid data type.

Here is a version of the sproc :

CREATE PROCEDURE SPXXX
AS 
BEGIN


DECLARE @calc numeric(18,2)
DECLARE @sql nvarchar(1500), @column_name nvarchar(50), @table_name nvarchar(50), @prmDef nvarchar(1500)
DECLARE @v1 nvarchar(50), @v2 nvarchar(50)
DECLARE @T AS MyTable

Set @column_name = 'EID'
Set @table_name = 'CTRY_S'
Set @sql = N'Select @calcOUT = SUM(datalength(@v1))/2 from @T';
Set @prmDef = '@v1 nvarchar(50),  @calcOUT numeric(18,2) OUTPUT';
EXECUTE sp_executesql @sql, @prmDef, @v1=@column_name, @T=@table_name, @calcOUT=@calc OUTPUT;

END
GO
  • 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-06-16T21:52:53+00:00Added an answer on June 16, 2026 at 9:52 pm

    You have a bunch of syntax errors in the example code. I am assuming that happened when you shortened the example, so I am not going to talk about them.

    Your main problem is, that the CREATE TYPE MyTable TABLE(..) command creates an object in the database. This type is not local to the procedure and stays in the database after the procedure finishes. The next time the procedure executes, you will get the error you have seen because the type indeed already exists.

    Just remove the create type statement and you should be fine.

    As for intellisense, you can never really trust it. Only execution tells if your statement is correct or not. You can use alternatives that are sold by other companies. They tend to be better, but non that I have come across is perfect.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an interesting SQL problem that I need help with. Here is the
Here is one very interesting problem. I am using SQL Server 2008. I have
Here's an interesting problem that I have just come across. It is possible to
Here's an interesting problem: I have some jQuery that looks like this: $(document).ready(function() {
I have an interesting problem to solve here that may require some creative direction.
Here's an interesting problem, I have a list of users that I list in
K here is an interesting problem We have an app that is presenting with
Here's an interesting problem. I have an ETL script written in c# that I
Well here is an interesting problem. Suppose I have a table on an sql
This is an interesting problem that I have searched here and all over my

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.