Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Convert string to uniqueidentifier

Status
Not open for further replies.

Marat

Programmer
Sep 18, 2000
17
KZ
Hello!
I need to get a result set from the table on SQL Server 7.0 by passing
parameter that refers to table's foreign key. Type of foreign key is
uniqueidentifier, type of parameter is string. But when parameter is
empty string ('') I recive an error 'can't convert string
to uniqueidentifier'.
What can I do to SQL Server interprets empty string as NULL?

Thanks
tolgambaev@hotmail.com [sig][/sig]
 
Myvar = ''
Myvar = .NULL. [sig]<p>Vlad Grynchyshyn<br><a href=mailto:vgryn@softserve.lviv.ua>vgryn@softserve.lviv.ua</a><br>[/sig]
 
Marat, if you are using SQL pass through (using SQLEXEC), use the literal 'NULL'. [sig]<p>Robert Bradley<br><a href=mailto: > </a><br><a href= - Visual FoxPro Development</a><br> [/sig]
 
Thanks to all, friends!
I have no problems with SQL path-through but I have a problem with parametrized remote view. Generally it uses a string parameter in uniqueid format ('xxx-xxx ...'), but when it is empty string (or string composed of spaces) SQL Server returns error. I tried 'iif(empty(?par),NULL,?par)' in remote view but it does not work.
Thanks again, Marat [sig][/sig]
 
If it is the VFP code that you are trying to work out, then modify your clause to read:

[tab]iif(isnull(par), 'NULL', ?par)
or, more appropriately,
[tab]NVL(, 'NULL', ?par)

If you need the clause to actually pass all the way to the server, then use SQL Server's ISNULL, which works a little bit different than VFP's:

[tab] ISNULL(?par, 'NULL')
[sig]<p>Robert Bradley<br><a href=mailto: > </a><br><a href= - Visual FoxPro Development</a><br> [/sig]
 
Thanks Robert and all!
I'll try it! [sig][/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top