Hi I want to write sql query in MVC4? I will explain my issue clearly
Sql Query
Select * from View_VisitorsForm where VisitingDate>='' and VisistingDate<=''
I tried to write this query in controller but i am getting error. i donno the perfect syntax to use in controller. My error which is mentioned in the below image.
Please any one tell me the correct solution for my problem.
Advance Thanks.
I think what you are looking for is the following:
SqlCommand cmd = new SqlCommand("Select * from view_VisitorsForm where VisitingDate between " + fromdt + " and " + todt + "",con);
Related
In an attempt to discover the possibilities and limitations of the Flink Table API for use in a current project, I was trying to translate a Flink SQL statement into its equivalent Flink Table API version.
For most parts, I am able to translate the statement using the documentation except for the window function row_number().
Flink SQL (working)
final Table someTable = tableEnvironment.sqlQuery("SELECT" +
" T.COLUMN_A," +
" T.COLUMN_B," +
" T.COLUMN_C," +
" row_number() OVER (" +
" PARTITION BY" +
" T.COLUMN_A" +
" ORDER BY" +
" T.EVENT_TIME DESC" +
" ) AS ROW_NUM" +
" FROM SOME_TABLE T"
)
.where($("ROW_NUM").isEqual(1))
.select(
$("COLUMN_A"),
$("COLUMN_B"),
$("COLUMN_C")
);
The closest I get, is the code below, but I don't seem to find what should be placed at the location of the question marks (/* ??? */).
Flink Table API (not working)
final Table someTable = tableEnvironment.from("SOME_TABLE")
.window(Over.partitionBy($("COLUMN_A"))
.orderBy($("EVENT_TIME").desc())
.as($("window"))
)
.select(
$("COLUMN_A"),
$("COLUMN_B"),
$("COLUMN_C"),
/* ??? */.over($("window")).as("ROW_NUM")
)
.where($("ROW_NUM").isEqual(1));
On https://nightlies.apache.org/flink/flink-docs-master/docs/dev/table/tableapi/#over-window-aggregation I find how it works for other window functions like avg(), min(), max()...; but the one(s) I require (row_number(), rank(), dense_rank()) are not (yet) described on this page.
My question is twofold:
Does an equivalent exist in the Flink Table API?
If so, what does it look like?
Additional information:
The Flink SQL variant works without issues (for this specific part).
I am experimenting with Flink 1.15.1.
Thank you in advance for you help!
The page where you can look this up is at https://nightlies.apache.org/flink/flink-docs-release-1.15/docs/dev/table/functions/systemfunctions/. You will see that ROW_NUMBER, RANK, and DENSE_RANK have examples for SQL, but not for Table API.
In the end, it shouldn't matter though. As you've done, you can just use SQL directly in your Table API program.
I am trying to get the date from the below filename using ssis expression.i get this file name from the variable
I have tried using findstring and reverse function but it still throwing cannot parse.
Any recommendtions pls
Variable
#[User::CurrentFile] : Z:\RETAIL DATA\HN_NLG\Supplier_report_by_Brand_Trend Micro_WC_20170327.xlsx
Need to get 20170327 and convert to 2017-03-27
Thanks in advance
You can use LEFT and RIGHT and SUBSTRING to achieve this, use the following expression to get the expected output:
SUBSTRING(LEFT(right(#[User::CurrentFile],13),8),1,4) + "-" + SUBSTRING(LEFT(right(#[User::CurrentFile],13),8),5,2) + "-" + SUBSTRING(LEFT(right(#[User::CurrentFile],13),8),7,2)
If #[User::CurrentFile] = 'Z:\RETAIL DATA\HN_NLG\Supplier_report_by_Brand_Trend Micro_WC_20170327.xlsx' you will get 2017-03-27
Try something like below, may be in a exec sql task or script and assign it to a variable for using further.
select Cast(CONVERT(date,
Reverse(Substring(Reverse('Z:\RETAIL DATA\HN_NLG\Supplier_report_by_Brand_Trend Micro_WC_20170327.xlsx'),
CHARINDEX('.',Reverse('Z:\RETAIL DATA\HN_NLG\Supplier_report_by_Brand_Trend Micro_WC_20170327.xlsx'),1)+1,
8))) as varchar(10))
I am trying to fetch data from Excel (as Database) when I put simple select query "select * from [Sheet1$]" its working fine and retrieve the data from sheet1. but when I put the conditional statement (where or Like) its throws the error "Error 2147217904 No value given for one or more required parameters".
Query Which is throw error ---
"select * from [Sheet1$] WHERE [Sheet1$].[ColName]= User"
OR
"select * from [Sheet1$] WHERE [ColName] = " & ColName_RunTime
OR
"SELECT * FROM [Sheet1$A2:E2] WHERE ColName =Yes"
Thanks in advance for help or solution.
The error is 0x80040E10L DB_E_PARAMNOTOPTIONAL No value given for one or more required parameters. See: https://technet.microsoft.com/en-us/library/ms171852(v=sql.110).aspx
Effectively, as you point out, there's something wrong with how you are supplying the values for your WHERE clause. It appears that you want to supply a string, so, they must be enclosed in single quotes.
"select * from [Sheet1$] WHERE [Sheet1$].[ColName]= 'User' "
I've a query that works OK against a MySQL database, but we've had to migrate the database and applications to SQL Server. Now I'm in trouble getting this query to work.
SELECT
complist.CompName,
complist.CompID,
componenttrace.Remark,
complist.McID,
complist.Station,
complist.Slot,
complist.Amount - complist.Used - ISNULL(complist.Correction,0)
FROM
complist, componenttrace
WHERE
complist.McID = 1004
AND complist.CompID = componenttrace.CompID
AND UPPER(complist.Station + '.' + complist.Slot) LIKE '%1.1%'
ORDER BY
complist.CompName, complist.CompID
On the application, the part that goes
AND UPPER(complist.Station + '.' + complist.Slot) LIKE '%1.1%'
is added automatically if there's any value on a given field (i.e. 1.1).
I have a SQL syntax problem, but don't know how to solve it. Can anyone shed some light here?
thanks,
Gustavo
Without error message is very hard to say what is wrong, but my bet is on the implicit join. Try
SELECT
complist.CompName,
complist.CompID,
componenttrace.Remark,
complist.McID,
complist.Station,
complist.Slot,
complist.Amount - complist.Used - ISNULL(complist.Correction,0)
FROM
complist
INNER JOIN componenttrace ON complist.CompID = componenttrace.CompID
WHERE
complist.McID = 1004
AND UPPER(complist.Station + '.' + complist.Slot) LIKE '%1.1%'
ORDER BY
complist.CompName, complist.CompID
I already have a table with 3 column (Id bigint, Title nvarchar(450), Description nvarchar(MAX)) in sql 2008
I decide convert Title and Description column into one XML column. but when trying to update get many error like "illegal name character" or "illegal qualified name character" and etc.
to solve this problem i just create windows application with subsonic 2.1 with below code
MyTable tbl = new MyTable(1111);
tbl.myXMLcol = "<Person><Title><![CDATA[ " + HttpUtility.HtmlEncode(tbl.Title) + " ]]></Title><Description><![CDATA[ " + HttpUtility.HtmlEncode(tbl.Description) + " ]]></Description></Person>";
tbl.Save();
then try to add "<?xml version=\"1.0\" encoding=\"utf-16\"?>" into first above string that get error "unable to switch the encoding".
Note: Also i using this method to remove illegal character, but not solve my problem
Note2: I trying to update Japanese record that get this error, but for English work properly.
Could you please help me.
Thanks.
I think you should be using UTF-8 encoding.
You can find out more about the encoding here:
http://www.ibm.com/developerworks/xml/library/x-utf8/
Also, you will find some more information here:
http://msdn.microsoft.com/en-us/library/ms131375.aspx
Why not do all of this directly in SQL Server ?? Could you try this:
UPDATE YourTable
SET XmlCol = CAST(N'<Person><Title>' + Title +
N'</Title><Description>' + Description +
N'</Description></Person>' AS XML)
WHERE ID = 12345
Does that work? If not, then maybe this one here?
UPDATE YourTable
SET XmlCol = CONVERT(XML, N'<Person><Title>' + Title +
N'</Title><Description>' + Description +
N'</Description></Person>', 2)
WHERE ID = 12345
The "2" for style will strip out things SQL Server doesn't like about XML - things like DTD and so forth. Maybe that'll help in your case, too?
I've had various troubles with SQL Server's XML support when importing XML from outside. Usually, one way or another, it ends up working, though :-)
Marc
After many research, I found article about my problem.
Please see Tarun Ghosh post