Skip to content
Advertisement

Tag: sql-server-2008

Select certain column only if condition met

I want to have a select that will not have fixed number of columns. Column OptionalColumn should be selected only if variable @check = 1 This is what I had (syntax is bad but maybe it explains my problem) It is crucial to have it only if @Check = 1 and not having it if @Check = 0. Is it

How to select from User Defined Table Type?

The above query returns me data but when I try to query the data within, it says dbo.udt_test not exists? https://msdn.microsoft.com/en-us/library/ms131086.aspx Referred to the above link, there should be no problem with the select query to display data. May I know if I missing something obvious here? Answer Because dbo.udt_test is a Table Type, not a Table instance. The link

SQL : remove last comma in string

I have a text memo field in SQL table that I need to remove the last character in the field if it’s a comma. So, for example, if I have these rows, I need to remove the commas from rows 2 and 4. The output would be: Any ideas? Answer Using REVERSE and STUFF: First, you want to TRIM your

Advertisement