SQL sp_help_operator - sql

Anyone know what group I need to belong to show up in the sp_help_operator list?

Judging from the docs for sp_help_operator, it looks like you need to explicitly add/remove operators using sp_add_operator and sp_delete_operator.
http://msdn.microsoft.com/en-us/library/aa238703(SQL.80).aspx

Related

Nesting Expressions

I have and expression:
=UCASE(Fields!MotherFullName.Value)​
and an expression:
=IIF(ISNOTHING(Fields!MotherFullName.Value) ,"-",Fields!MotherFullName.Value)
I want to nest them into one expression since they are operating on the same value, what must I do?
Using your code and taking a pass on evaluating the syntax...
=IIF(ISNOTHING(Fields!MotherFullName.Value) ,"-",UCASE(Fields!MotherFullName.Value)​)
What have you tried?
=IIF(ISNOTHING(UCASE(Fields!MotherFullName.Value)​) ,"-",UCASE(Fields!MotherFullName.Value))
should work, but I'd Advise you to Create Additional fields in your report and they use them to arrive at what you need, since the fields you dont include will not be displayed.
Also, Make sure you are making your edits in the expression window, not directly on your reports.
I finished creating the report above and it is working well, but when I upload it into the CRM Dynamics online, it is greyed out as shown in the picture bellow: What must I do?

Rails Activerecord query selective include

I am having trouble optimizing a large activerecord query. I need to include an associated model in my request but due to the size of the return set I only want to include a couple of the associated columns. For example I have:
Post.includes(:user).large_set
While I am looking for something like:
Post.includes(:user.name, :user.profile_pic).large_set
I need to actually use the name and profile pic attributes so Post.joins(:user) is not an option as far as I understand.
select is what you are looking for:
Post.select("posts.*, users.name, users.profile_pic").large_set
http://guides.rubyonrails.org/active_record_querying.html#selecting-specific-fields
You'll have to use join to accomplish what you want, as includes does not have this functionality. Or you could white your own includes method :-)

Using cast on a view in a Derby database that has multiple columns

This question is a quick one. I know that you could say something like SELECT CAST(someColumn AS otherType) FROM myView, where myView is a view in a Derby database, but is it combinable with other statements in a SELECT statement? In other words, could I say something like SELECT columnA, CAST(columnB AS otherType), someOtherColumns FROM myView, or would you have to cast YOUR ENTIRE QUERY? //I have been looking online for something that might help, but with no examples of this. I have even tried this on w3schools.com, but it was complaining that the database is read-only (somehow, cast() was changing the database!). Otherwise, I have found no working examples where someone has done something like what I am asking here.
I have found an answer to that question: yes, you can say something like I have said above in Derby. Here is an example: http://www.ibm.com/developerworks/library/os-ad-trifecta6/ //although I still couldn't use those methods on a database on w3schools.com!
You do not have to cast the entire freaking table; you could just cast one column at a time! Heck, in Derby, you could say DOUBLE(23), and it would return something like 23.000000!
I don't know what either Derby or w3schools.com means, but you need to understand that CAST is a function and all functions have syntax that is particular to whatever environment you are in. Many functions follow ANSI standard syntax but many others do not, especially in database languages. It doesn't make sense to use a function "on an entire query".
Here is a link to the Derby version 10.10 documentation for your DOUBLE function, a function that creates a floating point value (which is why you see it displayed as "23.000000"). When you get to that page, scroll down to the functions described in the section labeled "Built-in functions". You'll also see the documentation for the CAST function as well.
And note that although I've never heard of Derby before today, having access to the documentation like this means I'd fell comfortable developing code for it if the need ever came up.
In other words, always consult the documentation for the correct version of the database you are using!

Using WHERE for partial field match - How

Hello this is my first post and I am fairly new to SQL. Really what I am trying to find is an equivilent to MID$ where I can make updates based on part of a field.
UPDATE OurTable
SET UpdateField='Text-2008-001-old'
WHERE '2008' like ('%' || UpdateField) AND KeyField='1'
In other words I wand to update to 'Text-2008-001-old' where the field might currently be 'Line-2008-000-000'
The position of the 2008 does not change within the existing data so really I just need to update and fields that contain 2008 where the KeyField is '1'
If there is a good online resource for SQL syntax that I have not found yet please feel free to point me there.
Hope I have explained this OK and thanks in advance for all suggestions.
I think you just need to use LIKE:
UPDATE OurTable
SET UpdateField='Text-2008-001-old'
WHERE UpdateField LIKE '%2008%' AND KeyField='1'
Or if there are always dashes around it, perhaps LIKE '%-2008-%' would be better.
Good luck.
UPDATE OurTable
SET UpdateField='Text-2008-001-old'
WHERE UpdateField like 'Line-2008%' AND KeyField='1'
There are a number of wildcards to use with the LIKE operator (%,_,[],[^], etc.) -- explained here: http://msdn.microsoft.com/en-us/library/ms179859.aspx.
There is also the substring() function -- explained here: http://msdn.microsoft.com/en-us/library/ms187748.aspx, that is kind of like a MID function in other languages. (WHERE...LIKE SUBSTRING(...))

Is there a way to combine results from two IQueryable<T> using NHibernate & Linq?

I have two separate queries that both return the same IQueryable, and I'd like to combine them prior to projection. It looks like neither Union or Concat are implemented in Linq to NHibernate? Does anyone know how I might go about achieving this?
It's not possible. You'll have to do it on the client.
Example:
var allItems = queryable1.AsEnumerable().Concat(queryable2)
#Diago Mijelshon gives a good answer, but I would like to add that depending on what you're doing with the data, you may need to first cast it to an array or list so that NHibernate doesn't try to do any funny stuff with your operations.
I've used Entity Framework for years and I'm well familiar with this, and I've only used NHibernate a little bit, but the two tools appear to be similar in this regard.