Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

T-SQL Empty String without a String Literal

$
0
0

This is just for the fun of it.

How might one assign an empty string to an @variable without using a string literal?  Here is it with a string literal:

declare @myvar varchar(50);
set @myvar = '';
select '»'+@myvar+'«';

I came up with a couple ways to do it, but they were kludgy, at best.  What can you come up with?  Better solutions will work as expressions in WHERE clauses, too.


Dan Jameson
Associate Director of IT/DBA
Children's Oncology Group
http://www.ChildrensOncologyGroup.org


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>