Which table are Aliases stored in? - sql-server

In Sitecore I have created an alias called "bob" for a page.
For most items in Sitecore, the data is saved in the Items table in the database. You can easily see these if you search using the Item ID.
However whenever I search for an alias it returns no results:
select * from Items where ID ='0134A009-5D38-43C1-96C6-33C305543B7B'
Are aliases stored in a different location?
I have tried manually looking through all the tables and also ran a script which should search the whole database. If it is stored there then it looks like it is not in plain text.

Aliases like any other items are stored in the Items table.
You should check if you're looking for the Alias in the proper database. Maybe You're checking core or web database instead of master?
I've created a Bob alias in my env and query below returns 1 row containing alias details:
SELECT
*
FROM
[dbo].[Items]
WHERE
ID = '03275C36-32CE-47F7-AD28-9D5D2649E934'

Related

Implement a CONTAINS (IN) in DB2?

I have a DB2 9.X table with a column named summary.
Here's an example.
SUMMARY
updated www.name1.do.com
Went from www.there2.do.com towww.here1.do.com
Backed up theretherethere.do.this.com and restored to hellothereworld.go.com
Those are three different rows.
In my program I've got a list of URLs. I need to search the database in a way that returns all the rows if the summary column CONTAINS any of the URLs in my list.
Thanks
Store your URLs in a table (i.e. urls) and put '%' round your urls (i.e. %www.name1.do.com%) join both table using a cross join and select like this:
select summary
from basetable, urls
where summary like urls.likecolumn

MS Access default value from another table

I have two tables in a database. One is called salesreceipt and the other is salesreceiptlinedetail.
Each row in salesreceiptlinedetail has a field IDKEY that matches a field TxnID in a row in salesreceipt. There can be multiple rows in salesreceiptlinedetail that can match the same row in salesreceipt.
I have third party software that syncs my access database with Salesforce. The software only allows querying one table in the database at a time.
I need to automatically copy some of the fields from the salesreceipt table to new fields in the salesreceiptlinedetail table so I can sync the data correctly.
I'm very new to MS access. After trying many different things I landed on a solution that I think may work but I'm not sure how to do it. It looks like I can set the default value of a field. I'm thinking I need to do a DLookup to find the field I want to copy in the salesreceipt table and somehow use criteria to check the IDKEY matches the TxnID. I think I need to create a module with a function to do this but I'm not sure how and how to call it.
I may be way off on this. I could use some help or ideas. I've been researching for hours and could use a little push in the right direction. Thanks in advance.
Here's some things you can try, though I'm making some assumptions about the tables you've got and the result you're looking for.
So you've got a table called salesreceipt with an ID field TxnID and some other data (e.g. CustomerRef_FullName):
And then you've got a salesreceiptlinedetail table that has a field IDKEY field that matches back to salesreceipt table's TxnID field (i.e. a foreign key) and an empty field (e.g. FullName) that you want data for by matching the record back to the salesreceipt table.
I can think of a few ways of achieving this so that you end up with a table that has the information you want, but I'm not sure which is best for you. All these options shown are using Access 2013.
1) Get the data using a SELECT query and export those results across to your third-party software:
In Access, go to Create / Query Design:
Add your salesreceipt and salesreceiptlinedetail tables to your query and then close the Show Table window:
Click and drag on the TxnID field to the IDKEY field to create a join (represented by a line in Access):
Double-click on the IDKEY from your salesreceiptlinedetail and CustomerRef_FullName from your salesreceipt table; they should show as fields in the area at the bottom (if you have other fields you need then add those too, I'm just going on 1 field for illustrative purposes):
Click run to see the result of this query:
Hopefully this is showing a table that's starting to fill-in the blanks you want:
You can then save the query (right-click on the query table and chose "save" and name it whatever you want):
And export the results to a spreadsheet (assuming spreadsheet is the format your third-party software takes). Go to External Data / and then click "Excel" from the export group:
The query with the name you saved it as will be there in the Access Objects side-bar so that you can run it and export the results again (double-click on it to run it again):
The good thing about this method is that it's faster than using DLOOKUPs (these can be resource-heavy if you have a lot of records) and if there is new data/records in your salesreceipt and salesreceiptlinedetail tables, the query will run on that new data and include it in its results without you having to modify the query.
For your question though, it sounded like you might want to populate your salesreceiptlinedetail table with the data you need... this SELECT query will not do that. If you want to populate the actual salesreceiptlinedetail table you will need an UPDATE query...
2) Populate empty fields in salesreceiptlinedetail using an UPDATE query matched to records from salesreceipt
In this example, we're going to populate an empty field in salesreceiptlinedetail, namely the FullName field. We're going to do this by matching records in salesreceiptlinedetail to salesreceipt using the IDKEY and TxnID fields and then bring across the corresponding data in the CustomerRef_FullName field to the FullName field.
To do this, setup a new query the same way we did in (1) above and stop after you complete this stage:
Change the Query Type to an "Update" query:
Double-click the empty field you want to populate, e.g. FullName from the salesreceiptlinedetail table:
In the "Update To" box, type the name of the corresponding table and field you want to use to populate your empty field. Enclose the table and field each by a pair of square brackets and separate each by dot. So it should look something like this:
[salesreceipt].[CustomerRef_FullName]
In the criteria box, match your IDKEY and TxnID fields, like this:
[salesreceiptlinedetail].[IDKEY]=[salesreceipt].[TxnID]
Click "Run" and Access should show a warning that it is about to update some records in a table. Click Yes to allow it to do this:
If you go back to your salesreceiptlinedetail table, you should see that the once empty FullName field is now populated:
You can then save your UPDATE query for use again later - be aware that double-clicking on the query will open it AND run the UPDATE again (i.e. it will attempt to populate your salesreceiptlinedetail table with new data), so if you don't want that to happen you can right-click on it and open it Design View before opting to run it.
This method is good if you want to populate data in an already existing table, rather than essentially building a new table of results out of existing tables as described in (1) when we used a SELECT query.
If there's new data in salesreceiptlinedetail or salesreceipt, you'll want to run this UPDATE query again.
This is to add to Matt's answer. We have similar situations for a miniature reporting database, where we need to update the database several times through out the day. We wrap the query in a function and schedule a task in Windows to run every 4 hours that executes the Access function and updates the data.

How to find fields in a unknown table in a database?

Good morning!
I'm with the need to look in my database, one column of a table that does not know the name at first, what happens is the following:
In my application created for each project, a table is created which takes the name of this project, taking the given name and concatenating with the date and time of creation. So the name of this table is stored in another table called projects that have a field that tells the client that belongs to that project. When I do SELECT want to see the names of application projects related to the ID's of customers, browse the database tables behind those those customers and bring me these tables, so that we can finally see the desired fields.
Do not know if I could be clear, if they need more details just talk!
Thanks!
If I understood you correctly, you need to find the exact names of the tables that were named like your project plus they have some additional characters in their names (that look like dates and times).
Well, you can list all the tables that start with the name of your project, using a query like this:
SELECT *
FROM sys.tables
WHERE name LIKE 'yourprojectname%'
sys.tables is a system view where all your tables are listed.
'yourprojectname%' is a mask used for filtering through the list of tables. The % character is neccessary. It means 'any character or characters, any number of them (or none of them)'. (Without % the output would show you only one table whose name is exactly like your project's name. If such a table exists, that is.)

Find and replace all links in database

I want to find and replace in all db fields which contains a link in my database?how is that possible?
I have more tables but i don't know which tables :),i need to search programmatically.
I need to a method,example,GetContainsaLink(dbname) it should returns me tables and which field contains a link,
I have already a dictionary map old and new link for changing.
Example:
old link in a db field :images/123/789/picture/9D/10006685.jpg
new link in a db field :images/345/8001/picture/9D/10006685.jpg
Dump your from -> to mapping into a new table, and perform updates such as the below:
UPDATE MLT
SET link = LM.newlink
FROM mylinktable MLT
INNER JOIN linkmap LM
ON LM.oldlink = MLT.link
...to find which fields need updating - now that requires some knowledge of the data you're storing. A query such as SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE COLUMN_NAME LIKE '%link%' may be useful here.

What is a View in Oracle?

What is a view in Oracle?
A View in Oracle and in other database systems is simply the representation of a SQL statement that is stored in memory so that it can easily be re-used. For example, if we frequently issue the following query
SELECT customerid, customername FROM customers WHERE countryid='US';
To create a view use the CREATE VIEW command as seen in this example
CREATE VIEW view_uscustomers
AS
SELECT customerid, customername FROM customers WHERE countryid='US';
This command creates a new view called view_uscustomers. Note that this command does not result in anything being actually stored in the database at all except for a data dictionary entry that defines this view. This means that every time you query this view, Oracle has to go out and execute the view and query the database data. We can query the view like this:
SELECT * FROM view_uscustomers WHERE customerid BETWEEN 100 AND 200;
And Oracle will transform the query into this:
SELECT *
FROM (select customerid, customername from customers WHERE countryid='US')
WHERE customerid BETWEEN 100 AND 200
Benefits of using Views
Commonality of code being used. Since a view is based on one common set of SQL, this means that when it is called it’s less likely to require parsing.
Security. Views have long been used to hide the tables that actually contain the data you are querying. Also, views can be used to restrict the columns that a given user has access to.
Predicate pushing
You can find advanced topics in this article about "How to Create and Manage Views in Oracle."
If you like the idea of Views, but are worried about performance you can get Oracle to create a cached table representing the view which oracle keeps up to date.
See materialized views
regular view----->short name for a query,no additional space is used here
Materialised view---->similar to creating table whose data will refresh periodically based on data query used for creating the view
A view is a virtual table, which provides access to a subset of column from one or more table. A view can derive its data from one or more table. An output of query can be stored as a view. View act like small a table but it does not physically take any space. View is good way to present data in particular users from accessing the table directly. A view in oracle is nothing but a stored sql scripts. Views itself contain no data.
A view is simply any SELECT query that has been given a name and saved in the database. For this reason, a view is sometimes called a named query or a stored query. To create a view, you use the SQL syntax:
CREATE OR REPLACE VIEW <view_name> AS
SELECT <any valid select query>;

Resources