0

I have a stored procedure that selects some data and returns it. Now I also want to add a temp table, fill it with data and return it with the stored procedure.

I define it as follows:

create table #tempDateTable
(
    Name varchar,
    TempDate datetime
)

INSERT INTO #tempDateTable(Name, TempDate) values ('Smith', @myDate)
SELECT * FROM #tempDateTable

@myDate is parameter passed to the stored procedure.

When I execute the stored procedure it gives me:

Msg 8152, Level 16, State 14, Procedure date_samples_procedure, Line 90
String or binary data would be truncated.

What I find strange is that Line 90 is not any of the above shown lines, but if I remove all the code for this #tempDateTable, the stored procedure works normally.

2
  • 1
    Varchar without size it`s varchar(1) that why it truncates the data.
    – Mihai
    Commented Jul 4, 2014 at 12:35
  • Using a table-valued function is almost always more appropriate than this type of construct using a stored procedure + temporary table.
    – Jon Seigel
    Commented Jul 4, 2014 at 13:12

1 Answer 1

5

You should specify the length of the varchar column e.g. varchar(2000).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.