Lỗi getting the list of objects trong microsoft sql năm 2024
I have to migrate all my data from 2012 to 2008 server, Since restore doesn't work, I am generating scripts so that i can run on my 2008 server. Show My issue is when i generate scripts for DB script generation fails with following error. There are around 400 tables and the scripting fails somewhere in between while generating the script for the 200th table. I would appreciate an help on this. Thanks, in advance. Microsoft.SqlServer.Management.SqlScriptPublish.SqlScriptPublishException: An error occurred while scripting the objects. -> System.Data.SqlClient.SqlException: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. -> System.ComponentModel.Win32Exception: The wait operation timed out - End of inner exception stack trace - at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) at System.Data.SqlClient.TdsParserStateObject.ReadSniError(TdsParserStateObject stateObj, UInt32 error) at System.Data.SqlClient.TdsParserStateObject.ReadSniSyncOverAsync() at System.Data.SqlClient.TdsParserStateObject.TryReadNetworkPacket() at System.Data.SqlClient.TdsParserStateObject.TryPrepareBuffer() at System.Data.SqlClient.TdsParserStateObject.TryReadByteArray(Byte[] buff, Int32 offset, Int32 len, Int32& totalRead) at System.Data.SqlClient.TdsParserStateObject.TryReadChar(Char& value) at System.Data.SqlClient.TdsParser.TryReadPlpUnicodeCharsChunk(Char[] buff, Int32 offst, Int32 len, TdsParserStateObject stateObj, Int32& charsRead) at System.Data.SqlClient.TdsParser.TryReadPlpUnicodeChars(Char[]& buff, Int32 offst, Int32 len, TdsParserStateObject stateObj, Int32& totalCharsRead) at System.Data.SqlClient.TdsParser.TryReadSqlStringValue(SqlBuffer value, Byte type, Int32 length, Encoding encoding, Boolean isPlp, TdsParserStateObject stateObj) at System.Data.SqlClient.TdsParser.TryReadSqlValue(SqlBuffer value, SqlMetaDataPriv md, Int32 length, TdsParserStateObject stateObj) at System.Data.SqlClient.SqlDataReader.TryReadColumnData() at System.Data.SqlClient.SqlDataReader.TryReadColumnInternal(Int32 i, Boolean readHeaderOnly) at System.Data.SqlClient.SqlDataReader.TryReadColumn(Int32 i, Boolean setTimeout, Boolean allowPartiallyReadColumn) at System.Data.SqlClient.SqlDataReader.GetSqlValueInternal(Int32 i) at System.Data.SqlClient.SqlDataReader.GetSqlValue(Int32 i) at System.Data.SqlClient.SqlDataReader.GetProviderSpecificValue(Int32 i) at Microsoft.SqlServer.Management.Smo.DataEnumerator.FormatValueByType(String columnName, Int32 columnIndex) at Microsoft.SqlServer.Management.Smo.DataEnumerator.GetNextInsertStatement() at Microsoft.SqlServer.Management.Smo.DataEnumerator.MoveNext() at Microsoft.SqlServer.Management.Smo.SingleFileWriter.ScriptData(IEnumerable`1 dataScript, Urn table) at Microsoft.SqlServer.Management.Smo.FilePerObjectWriter.ScriptData(IEnumerable`1 dataScript, Urn table) at Microsoft.SqlServer.Management.Smo.ScriptMaker.ScriptDataToWriter(IEnumerable`1 dataScripts, Urn urn) at Microsoft.SqlServer.Management.Smo.ScriptMaker.ScriptCreateSpecialUrn(Urn urn, ScriptingPreferences sp, ObjectScriptingType& scriptType) at Microsoft.SqlServer.Management.Smo.ScriptMaker.ScriptCreate(Urn urn, ScriptingPreferences sp, ObjectScriptingType& scriptType) at Microsoft.SqlServer.Management.Smo.ScriptMaker.ScriptCreateObjects(IEnumerable`1 urns) at Microsoft.SqlServer.Management.Smo.ScriptMaker.ScriptUrns(List`1 orderedUrns) at Microsoft.SqlServer.Management.Smo.ScriptMaker.DiscoverOrderScript(IEnumerable`1 urns) at Microsoft.SqlServer.Management.Smo.ScriptMaker.ScriptWorker(List`1 urns, ISmoScriptWriter writer) at Microsoft.SqlServer.Management.Smo.ScriptMaker.Script(Urn[] urns, ISmoScriptWriter writer) at Microsoft.SqlServer.Management.SqlScriptPublish.SqlScriptGenerator.DoScript(ScriptOutputOptions outputOptions) - End of inner exception stack trace - at Microsoft.SqlServer.Management.SqlScriptPublish.GeneratePublishPage.worker_DoWork(Object sender, DoWorkEventArgs e) at System.ComponentModel.BackgroundWorker.OnDoWork(DoWorkEventArgs e) at System.ComponentModel.BackgroundWorker.WorkerThreadStart(Object argument) Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support. RAISERROR (Transact-SQL)
In this articleApplies to: Note The
0. New applications should use
1 instead of Generates an error message and initiates error processing for the session.
4 catalog view, or build a message dynamically. The message is returned as a server error message to the calling application or to an associated
5 block of a
6 construct. New applications should use THROW instead. Transact-SQL syntax conventions SyntaxSyntax for SQL Server and Azure SQL Database:
Syntax for Azure Synapse Analytics and Parallel Data Warehouse:
Argumentsmsg_idA user-defined error message number stored in the
4 catalog view using
8. Error numbers for user-defined error messages should be greater than 50000. When msg_id is not specified, msg_strA user-defined message with formatting similar to the
0 function in the C standard library. The error message can have a maximum of 2,047 characters. If the message contains 2,048 or more characters, only the first 2,044 are displayed and an ellipsis is added to indicate that the message has been truncated. Note that substitution parameters consume more characters than the output shows because of internal storage behavior. For example, the substitution parameter of %d with an assigned value of 2 actually produces one character in the message string but also internally takes up three additional characters of storage. This storage requirement decreases the number of available characters for message output. When msg_str is specified, msg_str is a string of characters with optional embedded conversion specifications. Each conversion specification defines how a value in the argument list is formatted and placed into a field at the location of the conversion specification in msg_str. Conversion specifications have this format: % [[flag] [width] [. precision] [{h | l}]] type The parameters that can be used in msg_str are: flag A code that determines the spacing and justification of the substituted value. Code Prefix or justification Description - (minus) Left-justified Left-justify the argument value within the given field width. + (plus) Sign prefix Preface the argument value with a plus (+) or minus (-) if the value is of a signed type. 0 (zero) Zero padding Preface the output with zeros until the minimum width is reached. When 0 and the minus sign (-) appear, 0 is ignored. # (number) 0x prefix for hexadecimal type of x or X When used with the o, x, or X format, the number sign (#) flag prefaces any nonzero value with 0, 0x, or 0X, respectively. When d, i, or u are prefaced by the number sign (#) flag, the flag is ignored. ' ' (blank) Space padding Preface the output value with blank spaces if the value is signed and positive. This is ignored when included with the plus sign (+) flag. width An integer that defines the minimum width for the field into which the argument value is placed. If the length of the argument value is equal to or longer than width, the value is printed with no padding. If the value is shorter than width, the value is padded to the length specified in width. An asterisk (*) means that the width is specified by the associated argument in the argument list, which must be an integer value. precision The maximum number of characters taken from the argument value for string values. For example, if a string has five characters and precision is 3, only the first three characters of the string value are used. For integer values, precision is the minimum number of digits printed. An asterisk (*) means that the precision is specified by the associated argument in the argument list, which must be an integer value. {h | l} type Used with character types d, i, o, s, x, X, or u, and creates shortint (h) or longint (l) values. Type specification Represents d or i Signed integer o Unsigned octal s String u Unsigned integer x or X Unsigned hexadecimal These type specifications are based on the ones originally defined for the
0 function in the C standard library. The type specifications used in
0 map to C language data types. Type specifications used in
0 are not supported by To convert a value to the Transact-SQL bigint data type, specify %I64d. @local_variableIs a variable of any valid character data type that contains a string formatted in the same manner as msg_str. @local_variable must be char or varchar, or be able to be implicitly converted to these data types. severityThe user-defined severity level associated with this message. When using msg_id to raise a user-defined message created using
8, the severity specified on
8. For severity levels from 19 through 25, the WITH LOG option is required. Severity levels less than 0 are interpreted as 0. Severity levels greater than 25 are interpreted as 25. Caution Severity levels from 20 through 25 are considered fatal. If a fatal severity level is encountered, the client connection is terminated after receiving the message, and the error is logged in the error and application logs. You can specify
1 to return the severity value associated with the error as shown in the following example.
Here is the result set.
stateAn integer from 0 through 255. Negative values default to 1. Values larger than 255 should not be used. If the same user-defined error is raised at multiple locations, using a unique state number for each location can help find which section of code is raising the errors. argumentThe parameters used in the substitution for variables defined in msg_str or the message corresponding to msg_id. There can be 0 or more substitution parameters, but the total number of substitution parameters cannot exceed 20. Each substitution parameter can be a local variable or any of these data types: tinyint, smallint, int, char, varchar, nchar, nvarchar, binary, or varbinary. No other data types are supported. optionA custom option for the error and can be one of the values in the following table. Value Description
2 Logs the error in the error log and the application log for the instance of the Microsoft SQL Server Database Engine. Errors logged in the error log are currently limited to a maximum of 440 bytes. Only a member of the sysadmin fixed server role or a user with ALTER TRACE permissions can specify WITH LOG. Applies to: SQL Server
3 Sends messages immediately to the client. Applies to: SQL Server, SQL Database
4 Sets the
5 and
6 values to msg_id or 50000, regardless of the severity level. Applies to: SQL Server, SQL Database RemarksThe errors generated by
9,
0,
6,
2,
3,
4, and
5 system functions. When
5 block. The error is returned to the caller if
5 blocks can use
5 block by using system functions such as
6 and
0 to retrieve the original error information.
5 is set to 0 by default for messages with a severity from 1 through 10. When msg_id specifies a user-defined message available from the sys.messages catalog view,
8 to add user-defined error messages and
0 to delete user-defined error messages.
0 function in the C standard library, while the Transact-SQL
4 statement does not. The
4 statement is not affected by
9 blocks, while a
5 block. Specify a severity of 10 or lower to use
9 block without invoking the
5 block. Typically, successive arguments replace successive conversion specifications; the first argument replaces the first conversion specification, the second argument replaces the second conversion specification, and so on. For example, in the following
3 replaces the first conversion specification of
4; and the second argument of
5 replaces the second conversion specification of
6
If an asterisk (
For example, both of the following
PermissionsSeverity levels from 0 through 18 can be specified by any user. Severity levels from 19 through 25 can only be specified by members of the sysadmin fixed server role or users with ALTER TRACE permissions. ExamplesA. Returning error information from a CATCH blockThe following code example shows how to use a local variable to supply the message text for a |