I am using Lucid Works to create index of solr.
Source : Database
I have two similar columns in my database, Party1, Party2.
I am using a SQL Statement like this;
SELECT top 1000000 OrderId as id
, Party1 as PartyNameFirst
, Party2 as PartyNameLast
FROM dbo.vw_SolrRPSTRD
I wanted to get both Party as a single fieled, seperated by ",". I know it is deals with multivalued field and splitby function.
But unable to get sample.
Please guide me in this.
Thanks In Advance....
Looks like you are using SQL Server. You can concatenate them in SQL itself and keep a single-valued Solr field:
SELECT top 1000000 OrderId as id,
Party1 + ', ' + Party2 as PartyName
FROM dbo.vw_SolrRPSTRD
Related
I have a Linked Server to the AS400 here. I'm trying to pull data from a field, but it is pulling over a million records when I only need about 20k.
I have a list of IDs that I need, and I'm trying to figure out how to pass that list into the OpenQuery.
Here is my OpenQuery:
SELECT * FROM OPENQUERY(AS400, '
SELECT
IMITNO, IMITD1, IMITD2, IMMFNO, IMBMTP, IMDSCO
FROM AS400.APLUS2FLE.ITMST
WHERE IMDSCO != ''Y''
')
I want to add WHERE IMITNO IN (SELECT item_id FROM as400_item_scope) but the as400_item_scope table is on the SQL machine, not the AS400. I looked at several examples and I can pass in a single variable, but I don't understand how to pass in a list/query like this.
I'm using latest SSMS, but SQL Server Version is 2008
You can't as far as I know...
Two options..
Insert the results of SELECT item_id FROM as400_item_scope into a (temporary?) table on the IBM i and then reference that table in your openquery.
build a comma delimited string with from the results of SELECT item_id FROM as400_item_scope and include that in your openquery string.
Depending on how many records are returned, you might run into issues with statement size trying to use option #2. Db2 for IBM i supports SQL statement of up to 2,097,152 bytes...
I want to send the date range and employee ids from SSRS to Oracle package. Does anyone knows how to do it? Even if i try to declare an oracle package with three in parameters from_date, to_date and employee_id it works fine with one employee id. But fails if i select multiple employees in SSRS web interface saying wrong number of parameters. Does anyone know how to handle this?
Normally with SQL and SSRS you would do something like
Select * From Table where Table.Field in #Param
Oracle is different of course and depends on the Connection Type you are using.
ODBC connection you would use something like:
Select * From Table where Table.Field = ?
Order of the parameters is important here so be careful.
OLEDB connection you would use something like:
Select * From Table where Table.Field = :Param
However, none of the above work with multi selecting of the Parameters. You could do this:
=”Select * From Table where Table.Field in (‘” + Join(Parameters!parameter.Value,”‘, ‘”) + “‘)”
or
=”Select * From Table where Table.Field in(” + Join(Parameters!parameter.Value,”, “) + “)” if the values or your field is only numeric.
Here are a couple of good articles that you can look at. It has a better explanation than I can give personally without more information; Details of your Oracle Environment, Connection Type, etc.
Quick Reference:
Be sure your Oracle version is 9 or greater, none of this works on
versions 8 or older.
When using parameters with Oracle, use a : instead of an # sign –
:param instead of #param.
Add an ‘ALL’ option to your datasets that supply values for
multivalued drop down parameters.
Check for the ALL in your where clause by using “where ( field1 in (
:prmField1 ) or ‘ALL’ in ( :prmField1 ) )” syntax.
You can execute your query from the dataset window, but can only
supply 1 value. However that value can be ‘ALL’.
Educate your users on ‘ALL’ versus ‘(select all)’ .
Another good article about Multiple Parameters in SSRS with Oracle: Davos Collective Which is referenced in the top portion.
Hope this helps!
We are migrating from SQL Server to Teradata database. All the views and tables are migrated. But the issue is that we aren't able to take the comments from each table.
In SQL Server we have a function called extended property which if used will get the comments from the respective tables/views. Badhri helped with providing a query for fetching the comment in Teradata in the same way but it doesn’t work in the expected way.
I tried inserting sample comments in columns and the below query is not fetching exact results. Can you please help?
Sample Query:
COMMENT ON COLUMN UtilityApp_DB.SQL_Views_Columns.ColumnNAME 'A Columnname for SQL Server!';
select 'COMMENT ON COLUMN '||trim(b.databasename)||'.'||trim(b.tablename) ||'.'||trim(b.columnname)||' IS '||''''||trim(b.commentstring)||''';'
FROM DBC.Columns b
WHERE b.CommentString IS NOT NULL
AND DatabaseName='UtilityApp_DB'
AND TableName in ('UtilityApp_DB.SQL_Views_Columns');
I created a table and tried inserting the values for the comment string in the table by copying the DBC Columns structure but still I can't get the comment string.
insert into UtilityApp_DB.commentstable (commentstring) values ('UtilityApp_DB.SQL_Views_Columns');
TableName in DBC.Columns does not include the database name and IS in your string concatenation should be AS.
SELECT 'COMMENT ON COLUMN '||trim(b.databasename)||'.'||trim(b.tablename) ||'.'||trim(b.columnname)||' AS '||''''||trim(b.commentstring)||''';'
FROM DBC.Columns
WHERE DatabaseName = 'UtilityApp_DB'
AND TableName IN ('SQL_Views_Columns');
I have a database (MS SQL) with a column that contains a query string. I want to take that query string and move it into a column that stores some settings in Json.
I could manually do this if it was only a few columns in one database, but this is part of a major upgrade that will be pushed out to over 50 sites. I'd like to have a T-SQL script that I could run on every database to perform this task for me.
Here's a sample of what the data will look like in the first column (as a query string):
KEY1=VALUE1&KEY2=VALUE2
I'd like to format that like so:
{"KEY1":"VALUE1","KEY2":"VALUE2"}
I'd appreciate any ideas you can throw my way!
Maybe you can use this
SELECT '{"' + REPLACE(REPLACE(#x, '=', '":"'), '&', '","') + '"}'
of course #x is your column I was testing with #x = N'KEY1=VALUE1&KEY2=VALUE2'
I've got a full text catalogue setup. It has a unique key count of 117 with 19 items. The table has 19 rows only.
The table has an NVARCHAR(50) field called ClientGuid. It's a guid with some weird text at the end.
eg..
8b6ef4a504dd1a57f079180e7f6eb4a0(-)
8b6ef4a504dd1a57f079180e7f6eb4a0(OK)
(and no, i didn't defined that text field data - we're sourcing it from a 3rd party API.
anways, this is my sql and the query i run against it. When i run the query, i get ZERO results back :(
ALTER FUNCTION [dbo].[Foo_HiJonSkeet]
(
#ClientGuid NVARCHAR(50)
)
RETURNS TABLE
AS
RETURN
(
SELECT KEY_TBL.[Key] as LogEntryId,
KEY_TBL.RANK as Relevance
FROM CONTAINSTABLE(LogEntries, ClientGuid, #ClientGuid) AS KEY_TBL
)
SELECT * FROM Foo_HiJonSkeet('8b')
Any suggestions?
Server is Sql Server 2008.
You can try the following construction:
SELECT * FROM Foo_HiJonSkeet('"8b*"')
adding the double quotes and an asterisk after the original search term. It should work.
But in the case if all the searches will be similar to the example you've posted above, I advise you to use LIKE statement instead of using full text search.