Storing data in a specific format using SQL? - sql

In one of my tables,I have an attribute that i want to store in a specific format like this
NV[0-9][0-9][0-9][0-9]. Ex: NV0001.
Can anyone help me?
P/s: sorry for the bad english :P

Related

grafana multi value query in timestream

i have some problems displaying my aws timestream data in grafana. I added as a global dashboard variable DevEUI with 3 different specific values. But when i am using the multivalue syntax ${DevEUI} in my query with more then one value i get everytime a error.
hope somebody can give me a hint.
Regards and thanks in advance
You are most probably having a list of values as the value of your multivalue Grafana variable, but you are still using the = operator in your query. Try ... and DevEUI IN ('${DevEUI}'). Or maybe without the single quotes or the parantheses... the exact syntax depends on your Grafana variable.
But, this is just an educated guess, since I cannot see neither your database schema nor the definition of this Grafana variable (both of which are important details in a question like yours, for future reference).
This is how I did it for a multivalued string value:
timestream_variable_name = ANY(VALUES ${grafana_variable_name:singlequote})
You might have to adjust the formatting Grafana applies to the concatenated variable value it generates, depending on your data type.
I know this is long after the original question but #alparius pointed me in the right direction so I wanted to update the fix for the problem Joe reported.
Use formatting to get the proper quotes/values when formatting your query. Something like this:
Select * from database where searchiterm IN (${Multi-Value_Variable:sqlstring})

How to convert the xml log into tabular output in Splunk

Am new to splunk and am trying to have the xml log data into splunk and create report.
I have xml data which is being fed to splunk server. below is the format of data am having
<str name=size>3.32mb</str>
I want to extract this details and have this transformed in tabular format. like below
Size | 3.32mb
I read something about xmlkv but i think it works on xml data like <size>3.32mb</size> but i am not sure how this will work for my requirement.
Could anyone please help me in understand this and also guide me to achieve this.
Thanks in advance.
Assuming that your xml data is in a field called "xml", you can extract what you want with this:
xpath outfield=name field=xml "//str/#name" | spath input=xml output=sizeval path=str | fields name, sizeval
See the splunk help about xpath and spath - the examples are good enough to guide you.

SQL Server - Need to check spelling errors in a column

Looking for a quick help.
In Sql, one of the table has a column(ntext). I need to find the count of spelling mistakes in the field. Association of MS Word dictionary would be great, however, can work with any other dictionary as well.
Any help on this would be great.
A possible way would be to read the text fields and pass them through a spellcheck library such as PyEnchant to count how many misspelt words there are (see Python: check whether a word is spelled correctly, https://pythonhosted.org/pyenchant/tutorial.html)
Otherwise, if you want to use MS Word spellcheck specifically, you can find some ideas here: Using MS Office's Spellchecking feature with C# and https://msdn.microsoft.com/en-us/library/windows/desktop/hh869748(v=vs.85).aspx.
Thanks for the reply Micah, however, I am looking for coding in sql.
For example one of my column value is - 'Liives' instead of 'Lives' then I should get 1 in column name 'Error_Count'
And if anyone can share the code for this then it would be a great help.
Thanks,
Victor

Convert table data into flat format using of Excel VBA

I have the following input data range
and the following desired output
The first block with Compals will be always the same - so 5 rows. Base Unit Current and Base Unit Later blocks will be variable - sometimes eight options and sometimes more than eight options.
I'm very new in excel vba so unfortunately I have no idea how to do that. Please, could anyone help me or give me some advice. Many thanks in advance.
Wonder you accept this kind of answer of not?
Instead of table, I think this kind of pivot may suitable your need:
I reform the table
Create the pivot table

DataBase design for store anketing data

my English is not well, so sorry for it.
I want to write the web-app for anketing. I mean, that it must be a site, where user may give answers on different questions. For example, it can be question with text type of answer, or checkbox, or lookup (comboBox).
And my problem is in data base architecture. I read a lot about Entity Attribute Value db pattern, One True Lookup Table I also read. But these patterns has problem (with ms sql) when building a sql-query for data selecting (report).
I hope somebody give me a good suggestion, and tell, what can I do with this proplem.
Thanks!
Almost everything can be represented as a string. Why not store a string in the database e.g. Text Type Answer or "true" "false" or ComboBox Value etc. Then simply convert the value from the database if necessary at runtime or in SQL if writing a query?
I feel Entity Attribute Value pattern is meant more for Entities which can have dynamic fields added etc, not so much for the problem you've posed here.
If necessary you could also add an additional column to the database table to specify the "type" of data being stored. You could then use that column to base your query convert statements on etc.