Not able to find values that are inserted into a table variable

I'm not able to find values that are inserted into a table variable. Has anyone seen this issue? If so, please share how you solved it. This link relates to a similar issue: http://stackoverflow.com/questions/1900857/how-to-see-the-values-of-a-table-variable-at-debug-time-in-t-sql.

SQ Server Version is 2008 R2.

1- I create a table variable inside the code of a stored procedure

2- Then I insert an average of 5000 alphanumeric values of type NVARCHAR from a permanent table into the the table variable .

3- When I retrieve the previously inserted values using a select from the table variable, the select result do not return all of the values. For example, values starting with 'W52' or 'N64' characters are not returned in the select result.

September 10th, 2015 1:37pm

Please rephrase your question and include your problem here..

Free Windows Admin Tool Kit Click here and download it now
September 10th, 2015 1:41pm

What is your sql server version ? Since your question has not much of clarity, its difficult to explain things. Please see below threads

https://social.msdn.microsoft.com/Forums/sqlserver/en-US/0df3c06e-79d6-492a-8c27-5b0cc74a3612/insert-variable-values-into-a-table?forum=sqlintegrationservices

http://www.sqlteam.com/article/using-table-variables

September 10th, 2015 5:56pm

Post your query and see what happens.
Free Windows Admin Tool Kit Click here and download it now
September 10th, 2015 6:00pm

I'm not able to find values that are inserted into a table variable. Has anyone seen this issue? If so, please share how you solved it. This link relates to a similar issue: http://stackoverflow.com/questions/1900857/how-to-see-the-values-of-a-table-variable-at-debug-time-in-t-sql. SQ Server Version is 2008 R2.

1- I create a table variable inside the code of a stored procedure

2- Then I insert an average of 5000 alphanumeric values of type NVARCHAR from a permanent table into the the table variable.

3- When I retrieve the previously inserted values using a select from the table variable, the select result do not return all of the values. For example, values starting with 'W52' or 'N64' characters are not returned in the select result.

September 14th, 2015 1:13pm

Put the following code after your INSERT ... SELECT ... and see what is the number to be returned:

SELECT @@ROWCOUNT

It should be 5000 if you insert 5000 rows of data.

Free Windows Admin Tool Kit Click here and download it now
September 14th, 2015 1:23pm

When I used SELECT @@ROWCOUNT  after the insertion of records from the perm table variable the result is 0.
September 14th, 2015 2:17pm

I'm not able to find values that are inserted into a table variable. Has anyone seen this issue? If so, please share how you solved it. This link relates to a similar issue: http://stackoverflow.com/questions/1900857/how-to-see-the-values-of-a-table-variable-at-debug-time-in-t-sql. SQ Server Version is 2008 R2.

1- I create a table variable inside the code of a stored procedure

2- Then I insert an average of 5000 alphanumeric values of type NVARCHAR from a permanent table into the the table variable .

3- When I retrieve the previously inserted values using a select from the table variable, the select result do not return all of the values. For example, values starting with 'W52' or 'N64' characters are not returned in the select result.

Free Windows Admin Tool Kit Click here and download it now
September 14th, 2015 2:19pm

Could you please share definition of "table" varibale?

https://msdn.microsoft.com/en-us/library/ms175010(v=sql.105).aspx

Excerpt from same link above -

Best Practices

Do not use table variables to store large amounts of data (more than 100 rows). Plan choices may not be optimal or stable when a table variable contains a large amount of data. Consider rewriting such queries to use temporary tables or use the USE PLAN query hint to ensure the optimizer uses an existing query plan that works well for your scenario.

September 14th, 2015 4:19pm

Can you post your code?
Free Windows Admin Tool Kit Click here and download it now
September 14th, 2015 4:21pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics