I have a database table named 'manufact' which has columns like below.
Whats the SQL command to Retrieve the manufacturer details whose names start with letter A to N.
Select * from manufacturer where manu_name like '[A-N]%';
Related
Is there any query that results from source table names and column table names using a mapping or mapping Id in informatica. This has been very hard and challenging
Like when we search up SELECT * FROM opb_mapping WHERE mapping_name LIKE '%CY0..%'
It is resulting in some details but I cannot find source table names and target table names. Help if you can.
Thanks.
You can use below view to get the data.
(Assuming you have full access to metadata tables.
select source_name, source_field_name,
target_name, target_column_name,
mapping_name, subject_name folder
from REP_FLD_MAPPING
where mapping_name like '%xx%';
Only issue i can see is, if you have overwrite sql, then you need to check sql for true source.
My overall goal is to create new tables by selecting columns in existing tables with certain patterns/tags in their column names. This is in SQL Server.
For example, I have a common need to get all contact information out of a company table, and into its own contact table.
I haven't been able to find a programmatic approach in SQL to express excluding columns from a SELECT statement based on string.
When looking to options like the COL_NAME function, those require an ID arg, which kills that option for me.
Wishing there was something built in that could work like the following:
SELECT *
FROM TABLE
WHERE COL_NAME() LIKE 'FLAG%'
Any ideas? Open to anything! Thanks!!
One trick could be to firstly using the following code to get the column names you desire:
select * from information_schema.columns
where table_name='tbl' and column_name like 'FLAG%'
Then concatenate them into a comma-delimited string and finally create a dynamic sql query using the created string as the column names.
I want to create an interface between 2 databases on SQL Server 2008+ to copy several similar named tables into one.
I have n tables that all have the same naming convention, for example:
SalesInvoicePlanning2014ver1
SalesInvoicePlanning2015ver1
SalesInvoicePlanning2015ver2
etc.
The numbers can vary and do not have a set start (or end), but are always of the "int"-Datatype.
I also have a table "tabledir" that contains all table names as list. (one field) There are a total of 30-40 entries in that list with (for me) undesired entries. In the above example I would need 3 of the 30 tables.
The plan is to use a loop container to
select Top 1([name]) from [tabledir] where name like 'SalesinvoicePlanning%'
and then use the result as variable in the following SSIS Data transfer task:
Select * from [variable]
However, I'm stuck with the SQL statement to give me the desired tablename on each iteration.
Performance is not really an issue. Any advice? Am I wrong trying to use a loop-container?
You can follow below steps -
Step 1 - You can first create SQL task to get all table names into one variable lets say, TableNames of type Object(recordset) using you query.
e.g. select ([name]) as TableName from [tabledir] where name like 'SalesinvoicePlanning%'
Step 2 - Add foreach loop container to iterate over this variable TableNames to take single table name into new variable current_table and add data flow into the container to import data to destination table. Your source query will be expression like -
Select column_names from current_table
i am working with sql and got stuck in issue,
i am using sql server 2012 r2.
i have a table (info) with 2 columns id (int) and names varchar(max).
in the names column i have stored coma(,) separated list of names, like marry,rita,johan,david,.
now i want to get the id where names is david.
select id from info where names='david'
how it is possible in sql, i know we can do it in c# by using string.substing but is it possible in sql?
Try this:
SELECT id FROM info
WHERE names LIKE '%david%'
It will return the id of the record if the column names contains 'david'.
Read more about LIKE operator here.
Hai,
I have two database and I want to select one value from one of the databases....
for that I want to pass one value and if that value is stored in the database I want to pick the id representing the value in the database.
that means the operation is that.....
first I select a row of data from one database by using a user control...
in that row there is a value (example "apple") and I want pass this value("apple") to the second database... in the second database the value("apple") having a id (example "australian") I want that the query search for that id("australian") and show that in the text box.
Please help me....
thanks to all advance....
example
first database
id name details
1 apple sweet
2 orange sweet
second database
id name details
Australian apple sold
Indian banana sold
Imagine that there are the two databases....
using a user control I select first row from first database and I want to pass that value apple to second database and find out the id australian from the second database and show that in a text box....
thank you.........
You can do a join between the two databases as long as you use the fully qualified prefix for each one.
I think you should go for the join , your query should look something like this
SELECT SecondDataBase.TableName.Id
FROM FirstDatabase.TableName INNER JOIN
SecondDataBase.TableName ON FirstDatabase.TableName.["Column contains Apple"] = SecondDataBase.TableName.["Column contains Apple"]
Fully qualified table name, which includes server name, db name, schema and table (e.g. MySqlServerInstance1.mydb1.dbo.table1) name will definitely work as long as one database server has a registered reference within a calling DB server. See this for things you have to do if you are using MS SQL Server: http://msdn.microsoft.com/en-us/library/ms188231.aspx
In MSSQL you normally reference a table using SchemaName.TableName
dbo.Fruit
The database is automatically determined by your connection string. FirstDatabase
So when you use dbo.fruit, the server automatically appends the database name to the table like
FirstDatabase.dbo.Fruit
If the user account has permission, you can select from a completely different database by specifying the database
SecondDatabase.dbo.FruitSales
To take it even further you can select from an entirely different SQL server if you have set up a linked server by specifying the linked server name like
SecondServer.ThirdDatabase.dbo.FruitShipping
So you can join between a table in your database and a table in your second database like
SELECT *
FROM FirstDatabase.dbo.Fruit AS F INNER JOIN
SecondDatabase.dbo.FruitSales AS FS ON F.Something = FS.Something
But you can even join between a table in your database and a table on a different server like
SELECT *
FROM FirstDatabase.dbo.Fruit AS F INNER JOIN
SecondServer.ThirdDatabase.dbo.FruitShipping AS FS ON F.Something = FS.Something