Convert MS Access Transform Query with Count into SQL Server PIVOT - ms-access

TRANSFORM Count(dbo_t_MARKETO_Comined_Analytics.[Email Address]) AS [CountOfEmail Address]
SELECT dbo_t_MARKETO_Comined_Analytics.[Email Address]
FROM dbo_t_MARKETO_Comined_Analytics
GROUP BY dbo_t_MARKETO_Comined_Analytics.[Email Address]
PIVOT dbo_t_MARKETO_Comined_Analytics.Source;

Related

Equivalent of SQL Server's CONTAINSTABLE in MySQL

I am converting a Query from SQL Server to MySQL but I have a problem converting the sentence contains table , because it uses rank .
I´ve looked for a similar property but I didn´t find anything , here is my Query at SqlServer
SELECT KEY_TBL.RANK
FROM CATS
INNER JOIN containsTABLE (CATS,(COLOR,CITY),'ORANGE',1000) AS KEY_TBL ON RUP.ID = KEY_TBL.[KEY]
ORDER BY RANK

SSIS - Replace Dynamic SQL With Variables

in my dataflow task I have OLEDB Source with the following query:
SELECT am.Code AS MeterCode
,am.Code AS NewMeterCode
,am.Description AS NewMeterDescription
,mr.TagName
,mr.RunHours
,mr.DateTo AS DateRead
FROM [19-AIS-004\VIJEOHISTORIAN].VijeoHistorianCPSData.dbo.RunHours AS mr
INNER JOIN dbo.astMeters AS am ON mr.TagName COLLATE SQL_Latin1_General_CP1_CI_AS = am.Code
the table 'mr' is the linked server table where i'm getting the Tagname, Runhours and DateTo and join it with astMeters table in order to import data from mr table to am table.
my problem is since the package is deployed in the remote server via vpn I need a way which I can created string parameter for the this table '[19-AIS-004\VIJEOHISTORIAN].VijeoHistorianCPSData.dbo.RunHours'.
Build your entire query as an SSIS string variable, and in your OLEDB Source, choose SQL Query From Variable and select the string variable that holds your query.

SQL query access pivot - error message 'field that has an invalid data type'

I'm running an SQL Query on MS Access.
the query looks like this:
TRANSFORM MIN(X_VALUE*MULTIPLE & ' ' & Y_VALUE)
SELECT A.ID
FROM ((MY_TABLE_A A
INNER JOIN MY_TABLE_B B ON B.ID = A.ID)
INNER JOIN MY_TABLE_C C ON C.FOO1_ID = A.FOO1_ID)
LEFT JOIN MY_TABLE_D D ON A.FOO2_ID = D.FOO2_ID
WHERE A.NUM ='FOO'
AND A.FOO_ID<>0
AND FOO3=1
GROUP BY A.ID PIVOT X_NAME IN('BLAH1', 'BLAH2')
when running this against local MDB file, it works.
when running this against Linked MDB (tables are linked to remote Oracle DB), I'm getting
ERROR [42000] [Microsoft][ODBC Microsoft Access Driver] The Microsoft
Access database engine could not execute the SQL statement because it
contains a field that has an invalid data type.
I've googled it, and couldn't find anything useful.
Any idea what can I do?
thanks.
The only statement in the query that even vaguely seems it would cause data type issues is the mixed types in the transform statement. Perhaps the following would work:
TRANSFORM MIN(CSTR(X_VALUE*MULTIPLE) & ' ' & CSTR(Y_VALUE))

Combining two columns in a select won't work

I need to combine values from 2 columns in a simple select statement using Access 2007 and ColdFusion 8. When I ran my query in Access I got the result without a problem, but when I put the query below in ColdFusion it won't run:
<cfquery name="Maj" datasource="#application.dsn#">
SELECT Majors & " " & GradeLevel
FROM Programs
WHERE Categories = 'Language'
ORDER BY Majors
</cfquery>
It produces the following error:
The following information is meant for the website developer for debugging purposes.
Error Occurred While Processing Request
Error Executing Database Query.
[Macromedia][SequeLink JDBC Driver][ODBC Socket][Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.
The error occurred in C:\Inetpub\wwwroot\test.cfm: line 4
2 :
3 :
4 : <cfquery name="Maj" datasource="#application.dsn#">
5 : SELECT Majors & " " & GradeLevel
6 : FROM Programs
Use single instead of double quotes around the space you're adding between Majors and GradeLevel.
SELECT Majors & ' ' & GradeLevel
FROM Programs
WHERE Categories = 'Language'
ORDER BY Majors
If your next issue is how to alias that field expression, the Access db engine may object when you use an existing field name as the alias. Avoid that problem by choosing an alias which doesn't match any of the field names.
SELECT Majors & ' ' & GradeLevel AS Majors_GradeLevel

i need Update Query from Mssql to Mysql in LINKED Server

Actually i need to connect Mssql to Mysql , Fortunately i did with MSSQL 2008 R2 linked server i made connection for Mysql
Now i want to write some queries for update at a time in both databases
when i am trying this query
update products set Stock=A.Stock from
(Select * FROM OPENQUERY(MYSQL,'Select * From products where Id=8')) A
inner join products B on b.Id=a.Id
the rows of MSSQL is updated from MYSQL
i need to update MSSQL to MYSQL also
please help me out ,i am working since last 4 days
MYSQL TO MSSQL UPDATION:
update products set Stock=A.Stock from
(Select * FROM OPENQUERY(MYSQL,'Select * From products')) A
inner join products B on b.Id=a.Id
UPDATE employee
SET LastName = ( Select FirstName from employee where FirstName = (SELECT * FROM
OPENQUERY(MYSQL, 'Select FirstName from employee where IndividualId=3')))
MSSQL TO MYSQL UPDATION:
UPDATE OPENQUERY (database, 'SELECT Stock FROM wings.products WHERE id =1')
SET Stock=999;