Quantcast
Channel: SQL Errors – SQLSERVERLEARNER
Viewing all 74 articles
Browse latest View live

Cannot use the %ls granularity hint on the table “%.*ls” because locking at the specified granularity is inhibited.

$
0
0

This error occurs when the lock cannot be applied on a specific table at a specified granularity.

It occurs for two granularity levels:
ROW
PAGE

For more information on ROW granularity locking error follow this link:
Cannot use the ROW granularity hint on the table because locking at the specified granularity is inhibited.

For more information on PAGE granularity locking error follow this link:
Cannot use the PAGE granularity hint on the table because locking at the specified granularity is inhibited.


The conversion of a varchar data type to a datetime data type resulted in an out-of-range value.

$
0
0

When you try to convert varchar datatype to datetime you would get this error when the value in varchar datatype does not represent the correct range of date.

Example Queries:

SELECT CAST( '2012-04-31' AS DATETIME)

Result:

Msg 242, Level 16, State 3, Line 1
The conversion of a varchar data type to a datetime data type resulted in an out-of-range value.

Other Sample queries:

SELECT CAST( '2012-04-30 24:00:00.000' AS DATETIME)
SELECT CAST( '2012-04-30 00:60:00.000' AS DATETIME)
SELECT CAST( '2012-04-30 00:00:60.000' AS DATETIME)
SELECT CAST( '2012-04-30 24:00:00.000' AS DATETIME)

Fix:
- Check if the values in the varchar data type are in the range of datetime datatype. Use this link to check the same: Range of datetime data type
- Check if the values for month, day, hours, minutes, seconds, milliseconds are valid.

Applicable to: SQL Server 2005, SQL Server 2008,SQL Server 2008 r2,SQL Server 2012, ASP, C#

FIX – Cannot Restore SQL Server 2000 Backup on SQL Server 2012

$
0
0

Unable to Restore SQL Server 2000 Backup on SQL Server 2012?

If you are trying to restore SQL Server 2000 backup on SQL Server 2008 you would be facing error like:


Msg 3169, Level 16, State 1, Line 1

The database was backed up on a server running version 8.00.2055. That version is incompatible with this server, which is running version 11.00.2100. Either restore the database on a server that supports the backup, or use a backup that is compatible with this server.

Restoring SQL Server 2000 backup to SQL Server 2012 is not supported.

Why?
According to MSDN In SQL Server 2012, you can restore a user database from a database backup that was created by using SQL Server 2005 or a later version.

How to restore then?
Fix/resolution:
Use SQL Server 2008 R2 as an intermediate source.

Steps:
1. First restore the SQL Server 2000 backup to SQL Server 2008 r2.
2. Then backup the database from SQL Server 2008 r2 and restore it on SQL Server 2012.

If you do not have SQL Server 2008 r2, You can download a trial version of SQL Server 2008 r2 from the below links.
http://msdn.microsoft.com/en-us/evalcenter/ff459612
http://www.microsoft.com/sqlserver/en/us/editions/previous-versions.aspx

Alternatively you can use SQL Server 2005 (or) SQL Server 2008 also as an intermediate source.

Following the above steps should help solve the problem.

Also verify the database backup on each target server before restoring: Verify SQL Server Database Backup

Msg 214, Level 16, State 2, Procedure sp_executesql, Line 1

$
0
0

When you try to execute sp_executesql you get the below error:


Msg 214, Level 16, State 2, Procedure sp_executesql, Line 1
Procedure expects parameter ‘@statement’ of type ‘ntext/nchar/nvarchar’.

Fix:
Add N Before the sql query.

Before:

EXEC sp_executesql 'SELECT 1'

After:

EXEC sp_executesql N'SELECT 1'

Applies to SQL Server 2000,SQL Server 2005,SQL Server 2008,SQL Server 2008 r2,SQL Server 2012, SSIS

Msg 206, Level 16, State 2, Line 6 Operand type clash: int is incompatible with xml

$
0
0

Error:

Msg 206, Level 16, State 2, Line 6
Operand type clash: int is incompatible with xml

This error comes up when you try to set XML variable with an int value.

Sample Code:

DECLARE @Var1 XML
DECLARE @Var2 INT

SET @Var2 = 1

SELECT @Var1 = @Var2

When you execute the above code you get this error at line 6
SELECT @Var1 = @Var2

Fix:
Check all the XML related variables, columns in the table, Arguments to stored procedure, function etc…
and validate if the correct XML value is set.

Applicable to SQL Server 2000,SQL Server 2005,SQL Server 2008,SQL Server 2008 r2,SQL Server 2012, SSIS

Duplicate column names are not allowed in result sets obtained through OPENQUERY and OPENROWSET. The column name “A” is a duplicate.

$
0
0

Error:

Msg 492, Level 16, State 1, Line 3
Duplicate column names are not allowed in result sets obtained through OPENQUERY and OPENROWSET. The column name “A” is a duplicate.

Possible Reason:
Column names being duplicate in the result set returned by OPENQUERY (or) OPENROWSET.

Example:

SELECT 1 AS A,2 AS A

Executes Successfully!!!

When the same query is used in the OPENROWSET.

SELECT * FROM OPENROWSET('SQLOLEDB',
                         'Server=(local);Trusted_Connection=Yes;Database=Master',
                         'SELECT 1 AS A,2 AS A')

Errors Out with Msg 492, Level 16, State 1, Line 3.

Fix/Resolution:
Make sure that each and every column in the result set returned by OPENQUERY (or) OPENROWSET has a different name.

SELECT * FROM OPENROWSET('SQLOLEDB',
                         'Server=(local);Trusted_Connection=Yes;Database=Master',
                         'SELECT 1 AS A,2 AS B')

appropriate to SQL Server 2005,SQL Server 2008,SQL Server 2008 r2,SQL Server 2012

Msg 8180, Level 16, State 1, Line 1 Statement(s) could not be prepared.

$
0
0

Error:

OLE DB provider “SQLNCLI10″ for linked server “(null)” returned message “Deferred prepare could not be completed.”.
Msg 8180, Level 16, State 1, Line 1
Statement(s) could not be prepared.
Msg 102, Level 15, State 1, Line 1
Incorrect syntax near ‘AS’.

In the above error the second error Msg 102 is thrown by the destination linked server, and the error 8180 is thrown by the local(source) server.

Reason for this error:
There could be synatax error in the query that is passed to the Linked Server(Other Server).

FIX/Resolution:
Execute the query that is passed to the Target server on the target server and check if there are any Syntax/Runtime errors.

SELECT * FROM OPENROWSET('SQLOLEDB',
                         'Server=(local);Trusted_Connection=Yes;Database=Master',
                         'SELECT * fromsys.tables')


OLE DB provider “SQLNCLI10″ for linked server “(null)” returned message “Deferred prepare could not be completed.”.
Msg 8180, Level 16, State 1, Line 1
Statement(s) could not be prepared.
Msg 102, Level 15, State 1, Line 1
Incorrect syntax near ‘fromsys’.

Now when I try to execute the query (shown below) on the target server, I came to know the syntax error in the statement.

SELECT * fromsys.tables

Fixed code:

SELECT * from sys.tables

Now I update the Original Code as follows. Now the code runs without error.

SELECT * FROM OPENROWSET('SQLOLEDB',
                         'Server=(local);Trusted_Connection=Yes;Database=Master',
                         'SELECT * from sys.tables')

Applicable to SQL Server 2008,SQL Server 2005,SQL Server 2008 r2,SQL Server 2012

Msg 207, Level 16, State 1, Line 1 Invalid column name ‘names’.

$
0
0

Error Message:

Msg 207, Level 16, State 1, Line 1
Invalid column name ‘names’.

Fix/Resolution:
1) Use correct alias names in your tsql code
2) Check if the column name exists in the table (or) Table valued function.
3) If the metadata is recently updated use sp_refreshsqlmodule to update metadata of the non schema bound objects.


Transaction (Process ID ) was deadlocked on resources with another process and has been chosen as the deadlock victim. Rerun the transaction.

$
0
0

Error Message:

Msg 1205, Level 13, State 56, Line 1
Transaction (Process ID 56) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction.

Why This Error?
Deadlock occurs when any two SQL server process IDs are locking a seperate resource and each one of them is trying to access the resource locked by the other process.

Fix/Resolution:
Check the below link for real time scenario and resolution to deadlock:
Deadlock Internals with Real Time Scenario – Explanation and Resolution

1) Try to use SQL server profiler to Analyze Deadlocks. http://msdn.microsoft.com/en-us/library/ms188246.aspx

2) In each script that has a transaction(locking) invoived, Begin the transaction as late as possible and commit it as soon as possible.

3) Try to set the optimal lock time value depending up on your script. Link: Using @@LOCK_TIMEOUT

4) SET the DEADLOCK_PRIORITY value in each script so that the priority processes wont be deadlocked. Link: SET DEADLOCK_PRIORITY

5) Use query hints for each TSQL Query.
Use WITH NOLOCK in select statements (when the waiting/locking is not needed)


ProcessID’s: Process ID 1 State 1 Process ID 2 State 2 Process ID 3 State 3 Process ID 4 State 4 Process ID 5 State 5 Process ID 6 State 6 Process ID 7 State 7 Process ID 8 State 8 Process ID 9 State 9 Process ID 10 State 10 Process ID 11 State 11 Process ID 12 State 12 Process ID 13 State 13 Process ID 14 State 14 Process ID 15 State 15 Process ID 16 State 16 Process ID 17 State 17 Process ID 18 State 18 Process ID 19 State 19 Process ID 20 State 20 Process ID 21 State 21 Process ID 22 State 22 Process ID 23 State 23 Process ID 24 State 24 Process ID 25 State 25 Process ID 26 State 26 Process ID 27 State 27 Process ID 28 State 28 Process ID 29 State 29 Process ID 30 State 30 Process ID 31 State 31 Process ID 32 State 32 Process ID 33 State 33 Process ID 34 State 34 Process ID 35 State 35 Process ID 36 State 36 Process ID 37 State 37 Process ID 38 State 38 Process ID 39 State 39 Process ID 40 State 40 Process ID 41 State 41 Process ID 42 State 42 Process ID 43 State 43 Process ID 44 State 44 Process ID 45 State 45 Process ID 46 State 46 Process ID 47 State 47 Process ID 48 State 48 Process ID 49 State 49 Process ID 50 State 50 Process ID 51 State 51 Process ID 52 State 52 Process ID 53 State 53 Process ID 54 State 54 Process ID 55 State 55 Process ID 56 State 56 Process ID 57 State 57 Process ID 58 State 58 Process ID 59 State 59 Process ID 60 State 60 Process ID 61 State 61 Process ID 62 State 62 Process ID 63 State 63 Process ID 64 State 64 Process ID 65 State 65 Process ID 66 State 66 Process ID 67 State 67 Process ID 68 State 68 Process ID 69 State 69 Process ID 70 State 70 Process ID 71 State 71 Process ID 72 State 72 Process ID 73 State 73 Process ID 74 State 74 Process ID 75 State 75 Process ID 76 State 76 Process ID 77 State 77 Process ID 78 State 78 Process ID 79 State 79 Process ID 80 State 80 Process ID 81 State 81 Process ID 82 State 82 Process ID 83 State 83 Process ID 84 State 84 Process ID 85 State 85 Process ID 86 State 86 Process ID 87 State 87 Process ID 88 State 88 Process ID 89 State 89 Process ID 90 State 90 Process ID 91 State 91 Process ID 92 State 92 Process ID 93 State 93 Process ID 94 State 94 Process ID 95 State 95 Process ID 96 State 96 Process ID 97 State 97 Process ID 98 State 98 Process ID 99 State 99 Process ID 100 State 100 Process ID 101 State 101 Process ID 102 State 102 Process ID 103 State 103 Process ID 104 State 104 Process ID 105 State 105 Process ID 106 State 106 Process ID 107 State 107 Process ID 108 State 108 Process ID 109 State 109 Process ID 110 State 110 Process ID 111 State 111 Process ID 112 State 112 Process ID 113 State 113 Process ID 114 State 114 Process ID 115 State 115 Process ID 116 State 116 Process ID 117 State 117 Process ID 118 State 118 Process ID 119 State 119 Process ID 120 State 120 Process ID 121 State 121 Process ID 122 State 122 Process ID 123 State 123 Process ID 124 State 124 Process ID 125 State 125 Process ID 126 State 126 Process ID 127 State 127 Process ID 128 State 128 Process ID 129 State 129 Process ID 130 State 130 Process ID 131 State 131 Process ID 132 State 132 Process ID 133 State 133 Process ID 134 State 134 Process ID 135 State 135 Process ID 136 State 136 Process ID 137 State 137 Process ID 138 State 138 Process ID 139 State 139 Process ID 140 State 140 Process ID 141 State 141 Process ID 142 State 142 Process ID 143 State 143 Process ID 144 State 144 Process ID 145 State 145 Process ID 146 State 146 Process ID 147 State 147 Process ID 148 State 148 Process ID 149 State 149 Process ID 150 State 150

Applied to SQL Server 2005,SQL Server 2008,SQL Server 2008 r2,SQL Server 2012

The data types varchar(max) and xml are incompatible in the add operator

$
0
0

Error Message:

Msg 402, Level 16, State 1, Line 5
The data types varchar(max) and xml are incompatible in the add operator.

This message occurs when you try to add varchar and xml data types.

Fix:
If you wanted to concatinate the XML Data type and Varchar Data type values, use the CAST Operator on XML Data type to convert into VARCHAR Datatype.

Example:

DECLARE @a XML
DECLARE @b VARCHAR(max)
SET @a = '<A></A>'
SET @b = 'ABC'
SELECT @b + @a

The Above code Gives Error 402.

Fixed Code:

DECLARE @a XML
DECLARE @b VARCHAR(max)
SET @a = '<A></A>'
SET @b = 'ABC'
SELECT CAST(@a AS VARCHAR(max))+@b

Conversion failed when converting the varchar value xx to data type int.

$
0
0

Error Message:

Msg 245, Level 16, State 1, Line 5
Conversion failed when converting the varchar value ’20.0′ to data type int.

This error occurs when you try to convert varchar datatype to datatype int and the value of datatype varchar is not compatable with int.

Example:

DECLARE @a INT
DECLARE @b VARCHAR(max)
SET @a = 11
SET @b = '20.0'
select @a+@b

When you execute the above code you get error 245.

Fix:
- Correct the data that is present in in the varchar data type
- Use the CAST or Convert operator to convert varchar to int

Fixed Code:

DECLARE @a INT
DECLARE @b VARCHAR(max)
SET @a = 11
SET @b = '20'
select @a+cast(@b as INT)


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000

The column prefix ‘A’ does not match with a table name or alias name used in the query

$
0
0

Error Message:

Msg 107, Level 15, State 1, Line 1
The column prefix ‘A’ does not match with a table name or alias name used in the query.

This error occurs when the correct table name/alias is not used in the select query.

Example:

SELECT a.* FROM SYS.tables 

When you execute the above code you get error message Msg 107.

Fix/Resolution:
Correct the select list with the correct table names or alias names.

SELECT sys.tables.* FROM sys.tables
SELECT tables.* FROM sys.tables
SELECT T.* FROM sys.tables T

The select list for the INSERT statement contains fewer items than the insert list. The number of SELECT values must match the number of INSERT columns.

$
0
0

Error Message:

Msg 120, Level 15, State 1, Line 2
The select list for the INSERT statement contains fewer items than the insert list. The number of SELECT values must match the number of INSERT columns.

This error occurs when the select clause contains lesser number of columns then that present in the insert clause.

Example:

DECLARE @VTABLE table(ID INT, NAME VARCHAR(100))

INSERT INTO @VTABLE(ID,NAME)
SELECT 1

Fix/Resolution:
Make the number of columns in select statement and insert statement equal.

Update the select statement with the number of columns equal to that of insert statement.

DECLARE @VTABLE table(ID INT, NAME VARCHAR(100))

INSERT INTO @VTABLE(ID,NAME)
SELECT 1,'ABC'

Update the insert statement with the number of columns equal to that of select statement.

DECLARE @VTABLE table(ID INT, NAME VARCHAR(100))

INSERT INTO @VTABLE(ID)
SELECT 1

The select list for the INSERT statement contains more items than the insert list. The number of SELECT values must match the number of INSERT columns.

$
0
0

Error Message:

Msg 121, Level 15, State 1, Line 3
The select list for the INSERT statement contains more items than the insert list. The number of SELECT values must match the number of INSERT columns.

This error occurs when the select clause contains more number of columns then that present in the insert clause.

Example:

DECLARE @VTABLE table(ID INT, NAME VARCHAR(100))

INSERT INTO @VTABLE(ID)
SELECT 1,'Devi'

Fix/Resolution:
Make the number of columns in select statement and insert statement equal

Update the select statement with the number of columns equal to that of insert statement.

DECLARE @VTABLE table(ID INT, NAME VARCHAR(100))

INSERT INTO @VTABLE(ID,NAME)
SELECT 1,'ABC'

Update the insert statement with the number of columns equal to that of select statement.

DECLARE @VTABLE table(ID INT, NAME VARCHAR(100))

INSERT INTO @VTABLE(ID)
SELECT 1

A TOP N value may not be negative

$
0
0

Error Message:

Msg 127, Level 15, State 1, Line 1
A TOP N value may not be negative.

This error occurs when you try to specify negative value for the TOP Clause in the select statement.

Simple Example:

SELECT TOP(-5) * FROM sys.tables

When the above code is executed error message 127 would occur.

Fix/Resolution:

Update the TOP clause with a positive value.

SELECT TOP(5) * FROM sys.tables

In the above code -5 is changed to 5.


String or binary data would be truncated

$
0
0

Error Message:

Msg 8152, Level 16, State 14, Line 4
String or binary data would be truncated.
The statement has been terminated.

Why this error?
This error occurs whan the size of data that is inserted into a column is greater than the size of the column.

Example:

DECLARE @Temp table(Col1 VARCHAR(10))


INSERT INTO @Temp(Col1)
SELECT '12345678901'

Fix/Resolution:

Increase the size of the column so that the length of the column is greater than or equal to length of the value that is inserted.

DECLARE @Temp table(Col1 VARCHAR(11))


INSERT INTO @Temp(Col1)
SELECT '12345678901'

Decrease the size of the data (value) so that the length of the data is lesser than or equal to length of the column.

DECLARE @Temp table(Col1 VARCHAR(10))


INSERT INTO @Temp(Col1)
SELECT '1234567890'


State 1 State 2 State 3 State 4 State 5 State 6 State 7 State 8 State 9 State 10 State 11 State 12 State 13 State 14 State 15 State 16 State 17 State 18 State 19 State 20 State 21 State 22 State 23 State 24 State 25 State 26 State 27 State 28 State 29 State 30 State 31 State 32 State 33 State 34 State 35 State 36 State 37 State 38 State 39 State 40 State 41 State 42 State 43 State 44 State 45 State 46 State 47 State 48 State 49 State 50 State 51 State 52 State 53 State 54 State 55 State 56 State 57 State 58 State 59 State 60 State 61 State 62 State 63 State 64 State 65 State 66 State 67 State 68 State 69 State 70 State 71 State 72 State 73 State 74 State 75 State 76 State 77 State 78 State 79 State 80 State 81 State 82 State 83 State 84 State 85 State 86 State 87 State 88 State 89 State 90 State 91 State 92 State 93 State 94 State 95 State 96 State 97 State 98 State 99 State 100 State 101 State 102 State 103 State 104 State 105 State 106 State 107 State 108 State 109 State 110 State 111 State 112 State 113 State 114 State 115 State 116 State 117 State 118 State 119 State 120 State 121 State 122 State 123 State 124 State 125 State 126 State 127 State 128 State 129 State 130 State 131 State 132 State 133 State 134 State 135 State 136 State 137 State 138 State 139 State 140 State 141 State 142 State 143 State 144 State 145 State 146 State 147 State 148 State 149 State 150 State 151 State 152 State 153 State 154 State 155 State 156 State 157 State 158 State 159 State 160 State 161 State 162 State 163 State 164 State 165 State 166 State 167 State 168 State 169 State 170 State 171 State 172 State 173 State 174 State 175 State 176 State 177 State 178 State 179 State 180 State 181 State 182 State 183 State 184 State 185 State 186 State 187 State 188 State 189 State 190 State 191 State 192 State 193 State 194 State 195 State 196 State 197 State 198 State 199 State 200
Line
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000
entity framework sqlstate 22001 statement has been terminated the step failed

Cannot roll back xxxxxxxx. No transaction or savepoint of that name was found.

$
0
0

Error Message:

Msg 6401, Level 16, State 1, Line 1
Cannot roll back t2. No transaction or savepoint of that name was found.

This error orccurs when the Transaction or save point name that is specified in the rollback transaction is not found.

Example:

BEGIN TRAN
SAVE TRAN T1
ROLLBACK TRAN T2
ROLLBACK TRAN

When the above code is executed error 6401 will occur as the save point with the name T2 cannot be found in Line 3

Fix/Resolution:
Update ROLLBACK Tran/TRANSACTION Query with the correct name of the Save Point.

BEGIN TRAN
SAVE TRAN T1
ROLLBACK TRAN T1
ROLLBACK TRAN

Cannot issue SAVE TRANSACTION when there is no active transaction.

$
0
0

Error Message:

Msg 628, Level 16, State 0, Line 1
Cannot issue SAVE TRANSACTION when there is no active transaction.

Why This Error?
- This error occurs when SAVE TRANSACTION/TRAN command is issued prior to issuing BEGIN TRANSACTION Command.
- The transaction could be commited/Rollbacked before issuing SAVE TRANSACTION command

Examples:

SAVE TRAN Tran1

OR

BEGIN TRAN
ROLLBACK TRAN
SAVE TRAN Tran1

Fix/Resolution:

Check for BEGIN TRAN command before SAVE TRAN command.
Check if the tran is commited/rollbacked before SAVE Tran Command.
If the transaction needs to be saved then make sure that the SAVE TRAN command is issued after the BEGIN TRAN command and before the COMMIT/ROLLBACK Tran command.

Incorrect syntax near the keyword into

$
0
0

Error Message:


Msg 156, Level 15, State 1, Line 2
Incorrect syntax near the keyword ‘INTO’.

This error occurs when the syntax of the select into statement is not correct.

Example:

SELECT * FROM 
Product INTO ProductBackup

When the above code is executed error message 156 would occur.

Fix/Resolution:

- Check the SELECT INTO syntax.
- Make sure that the INTO Statement is after the column list( or *) and before FROM.

Fixed Code:

SELECT * INTO ProductBackup 
FROM Product

Msg 4621 Level 16 State 10 Line 1 Permissions at the server scope can only be granted when the current database is master

$
0
0

Error Message:

Msg 4621, Level 16, State 10, Line 1
Permissions at the server scope can only be granted when the current database is master

This message occurs when the Server scope permissions are tried to be modified from any other database other than master.

Example:

USE AdventureWorksDW2008R2
GRANT VIEW SERVER STATE TO USER1
USE AdventureWorksDW2008R2
REVOKE VIEW SERVER STATE TO USER2

Fix/Resolution:
Change the database to master.

USE MASTER
GRANT VIEW SERVER STATE TO ABC
Viewing all 74 articles
Browse latest View live