Why this error (text and text are incompatible?) - tsql

please help,
I am unsure why I keep getting this error 'The data types text and text are incompatible in the equal to operator.'
When I run this code it works;
SELECT [startername]
,[endername]
FROM [master].[dbo].[MATCH]
WHERE enderpoints = 0.0
When I run this code it works;
SELECT name FROM PLAYERS WHERE TEAM like 'Stars' OR TEAM like 'Aces'
When I try to do both I get an error, what am I missing?
SELECT [startername]
,[endername]
FROM [master].[dbo].[MATCH]
WHERE enderpoints = 0.0
AND startername IN (SELECT name FROM PLAYERS WHERE team like 'Stars' OR team like 'Aces')

Related

SharePoint REST: Column does not exist error

I'm calling a REST API with a SharePoint Designer workflow on SharePoint online. I'm setting the column name with a variable, and when i put the variable into my URL to call it it says "Column [name] does not exist".
Annoying part is when I call just /items? I can see the column in the result, but if I try select it or filter by it I get 'does not exist'. I have alot of these columns similarly named, and I get the error for all of them.
I am using the internal name, I have tried adding "OData_" to the front. I've tried typing the url manually in the browser and entering values (incase the variable was causing issues) but I get the same error, column does not exist. but i can see it them I call all items. :(
so I have quite a few columns with naming convention "[Q#] Score [#]" eg "Q4 Score 2". The internal name that's clearly appearing in the full items results is "Q4_x0020_Score_x0020_2".
This works:
https://MYSITE.sharepoint.com/sites/portal/intranet/CorpServices/QSR/_api/web/lists/GetbyTitle('Audit')/Items?
and I get big full normal REST results that includes the line:
0
However if I try:
https://MYSITE.sharepoint.com/sites/portal/intranet/CorpServices/QSR/_api/web/lists/GetbyTitle('Audit')/Items?$Select=Q4_x0020_Score_x0020_2
Then I get:
-2146232832, Microsoft.SharePoint.SPExceptionColumn 'Q4_x0020_Score_x0020_2' does not exist. It may have been deleted by another user.
I expect to be able to select that column (and the dozens like it) but none work. I've searched all similar problems on the forum and they've usually got a spelling mistake or forgot the ODATA_ but i cant seem to get the problem. Please help.
It seemed to be working intermittently.... So it was in fact just a naming error...... Half of the columns were [Q#]_x0020_Score_x0020_[#] and half were [Q#]_x0020_score_x0020_[#]. The word "Score" was capitalized on some and not others. I Didn't realize the HTTP Calls were case sensitive. Now I have added a bunch of if statements to handle the different variations haha. Thanks for reading.
Judging by the naming convention you are on an older version of SharePoint. The x0020 is the value for a space. Ideally when you first create the column you would name it without the spacing. For example UserInformation. Then come in and edit the name after the fact and call it User Information. If you click on the title name and look at the URL, you will see what the actual name of the column is at the end of the URL. It is case sensitive because you can have a column named score and Score which is ultimately why it wasn't working.
Must load all fields like this
var lists = context.Web.Lists;
context.Load(lists);
context.ExecuteQuery();
CamlQuery query = new CamlQuery();
query.ViewXml = #"";
var list = lists.GetById("file.guid");
var listitems = list.GetItems(query);
context.Load(listitems);
context.ExecuteQuery();
var creationInformation = new ListItemCreationInformation();
var newItem=list.AddItem(creationInformation);
var fields = list.Fields;
context.Load(fields);
context.ExecuteQuery();

Syntax error on DB2 XMLELEMENT

I get this error when trying out this command in the BIRT Classic Models sample database in Data Studio
select xmlelement(name "custno", customers.customernumber) from customers
Syntax error: Encountered "\"custno\"" at line 1, column 24.
I do not know how to correct it.
Thanks.
I'm not familiar with db2, but according to this your statement looks quite alrigth (although I'd place an alias to name this field...)
But this
Syntax error: Encountered "\"custno\"" at line 1, column 24.
seems to be a quite clear hint, that your error is connected to the NAME of the element.
I'm pretty sure, that this statement was created on string level.
Did you try to escape the "-characters with \"?
The SQL reaching the engine might look like
select xmlelement(name \"custno\", customers.customernumber) from customers
or
select xmlelement(name "\"custno"\", customers.customernumber) from customers
... which is wrong of course...
But to be honest: just guessing...

command level parameters in crystal reports

I have a report having 2 parameters carton and location.
Suppose if I didn't gave any value among those then it should give all values.
So created 2 command level parameters.Its showing all values whenever I didnt gave any values in parameters.
But even If I gave some value in either carton or location but still its showing all values.
Please suggest what is the problem
SELECT
crt.carton_no, crtd.part_no, SUM(crtd.quantity) AS quantity,
crtd.barcode, crtd.item_description
, crt.put_away_location AS putAway
FROM
carton crt, carton_details crtd
WHERE
crt.carton_id = crtd.carton_id
AND crt.status = 'N' AND
( crt.carton_no like '{?cartonno}' or '{?cartonno}' like '%' ) and (crt.put_away_location LIKE '{?location}' or '{?location}' like '%')
GROUP BY
crt.carton_no, crtd.carton_id, crtd.part_no
ORDER BY
crt.put_away_location, crt.carton_no
I guess your query is always taking true ignoring or condition... try using Case
where
CASE WHEN {?cartonno} Like ""
THEN
'{?cartonno}' like '%'
ELSE
crt.carton_no like '{?cartonno}'
END
Note: I don't know which database you are using above is just an example of SQL... you can change it as required and use similarly for other parameter in where clause

ask for record id on form open (microsoft access 2013)

I am willing to create a form which upon it's opening, it should prompt the user to enter the record ID it should open on.
the form needs to open the record ID specified upon its launch, not an assigned ID previously, I think it should do the prompting like something the [] do in queries.
any help would be appreciated
thanks in advance
This is pretty straight forward. You can do this either of 2 ways:
Create a form with a Textbox (or Combobox) where the user will enter an ID or select it from a list. Then create a button called something like btnSubmit. Behind the button, in code, you would enter something like:
sqlRecordSource = "SELECT * FROM MyTable WHERE RecordID = " & Me.MyTextboxName & ""
DoCmd.RunSQL sqlRecordSource
The other option you could have is that you create a query, call it qryRecordID, and the SQL would look like this:
SELECT * FROM MyTable WHERE RecordID = [Enter a RecordID]
You could then run that query anywhere and not need a separate form with a RecordID textbox, because the query will automatically prompt you for one.

simple where clause SSRS 2005 parameter not working

this should be a simple thing but I've spent hours to no avail. Basically, I need to look up a salesrep # in a SQL database using the user's Window's user id. The format of the user id is
"Norstar\kjones" and I need the "kjones" portion of it.
using the split function, I am able to pull just the 'kjones' part out:
split(User!UserID,"\").GetValue(1)
I've created a parameter called SlsmnNum and created a dataset to be used to look up the salesrep # using the user id (the slsm_num field is a varchar, not an integer):
select slsm_num from Salesman_Msid where slsm_msid = ''' + split(User!UserID,"\").GetValue(1) + '''
However, I get no results. How can I get the select to work?
alternatively, I tried the following:
in parameter SlsmnNum, I set the default to an expression using:
split(User!UserID,"\").GetValue(1) and this returns 'kjones', as expected.
I created a SECOND parameter (which is positioned BELOW the SlsmnNum parameter), SlsmnNum2, that has a default (and an available) value using a query, which is a dataset containing the following select statement:
select slsm_num from Salesman_Msid where slsm_msid = (#SlsmnNum)
When I run the query on the Data tab, when I type in 'kjones' into the parameter box, it returns '1366', the salesrep # I'm expecting.
But, when I Preview the report, all I get in SlsmnNum2 box is Select a Value and nothing is there (it should return '1366').
Any help would be greatly appreciated!
Try your first approach with Query Text as
="select slsm_num from Salesman_Msid where slsm_msid = '" & split(User!UserID,"\").GetValue(1) & "'"