The MS-SQL executes a stored procedure with the guid Parameter

Source: Internet
Author: User

Possible errors:

Error converting data type varchar to uniqueidentifier

Or

Conversion failed when converting from a character string to uniqueidentifier

 

You must first convert the string to the uniqueidentifier type.

 

Example:

 
Declare@ GuidUniqueidentifier select@ Guid=Cast('16d85cfe-360f-44af-bc79-33bc1e89b698'As uniqueidentifier)ExecProc_getsiteusage @ guid

 

To create a new guid, do the following:

Declare@ GuidUniqueidentifierset@ Guid=Newid()Print'Value of @ guidis :'+Convert(Varchar(255),@ Guid)

 

 

Refer:

Generate GUID (unique identifier) in SQL Server

Http://www.dotnetspider.com/resources/4866-Generate-GUID-Unique-Identifier-SQL-Server.aspx

Failed to convert parameter value from string to guid

Http://social.msdn.microsoft.com/Forums/en-US/sqlreportingservices/thread/b3690c51-32fd-42cf-8c40-78407b9c4cc0

 

For more information about how to use stored procedures to obtain data, see

Http://www.informit.com/articles/article.aspx? P = 31283 & seqnum = 4

For the difference between cast and convert, refer

Http://www.informit.com/articles/article.aspx? P = 31283 & seqnum = 4

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.