All Questions
581
questions
0
votes
1
answer
75
views
How to ignore trailing whitespace? [duplicate]
Say a SQL table contains a column of char(10), and a record contains the value "ABC" in that column. Entity Framework will pass ABC ("ABC" with 7 trailing spaces) when asked ...
1
vote
2
answers
55
views
Is there a better way to get full row of calculated group by using LINQ
This question is a further question to https://stackoverflow.com/questions/157786/how-do-i-get-the-max-row-with-a-group-by-in-linq-query. Besides the max value and the group key, I need the every ...
0
votes
0
answers
113
views
Script in dynamic SQL for Data Validation when there is multiple source and target
There are more than 18 source systems, which are the real source of data.
All the source systems have a different schema.
The target tables were built on SQL Server.
The column name in the target ...
2
votes
0
answers
118
views
Timeout exception and 'Cannot access destination table #name' on bulk.WriteToServer(readerTabel) with small timeout /SQL wait time/block
I have a problem with SqlBulkCopy that sometimes(pretty often) i get a timeout error and an sql error 'Cannot access destination table #temp'.
My timeout on bulkcopy is 5 seconds. After further ...
1
vote
2
answers
537
views
sql server how to reuse where conditions in multiple queries with different returning results
I have a huge sql query with multiple joins and bundle of where conditions (filters). The query returns results with pagination or page wise. Now in other case I need only a total count as result ...
0
votes
1
answer
236
views
How to execute a c# code within an SQL procedure?
I had a project in SSIS that I now want to run just by using T-SQL.
Basically I have a datasource where I download csv files everyday into a directory. I have a full c# code that does exactly that and ...
1
vote
1
answer
214
views
SqlDataReader.GetSchemaTable returns data type = int when all values are null
The following code snippet:
using (DataTable schemaTable = reader.GetSchemaTable())
{
for (int i = 0; i < reader.FieldCount; i++)
{
DataRow drow = schemaTable.Rows[i];
...
-2
votes
1
answer
265
views
How to insert data to table when one of the columns is set to current timestamp on insert? [duplicate]
I have a date column of type datetime and I want it to update to the current date and time on every insert.
I set the column to Default Value or Binding = (getdate())
But still, the code itself throws ...
0
votes
1
answer
240
views
Query doesn't execute due error within c# code due to internal parameter
I think I'm missing something obvious here. The query executes in SQL server no problem. I've googled around and I found out you can use AddWithValue on the SQL command for the parameter @UserID but ...
-2
votes
1
answer
48
views
Translating SQL to C#: Select name in key-value pair with the highest value after applying a function to its value and filtering based on a condition?
I have the following almost-English SQL.
SELECT [NAME]
FROM [PAIRS]
WHERE condition([NAME])
HAVING function([SCORE]) = MAX(function([SCORE]))
Assume that:
PAIRS is a two-column table translating a ...
-1
votes
1
answer
126
views
Status of SQL-query
I want to know, if the SQL-query was executed succesful. In C# I execute the query like this:
using (SqlConnection conn = new SqlConnection("<placeholder>"))
{
conn.Open();
...
-1
votes
4
answers
119
views
Search in the database
This Messages form display table with these informations (ID,FROM,TO,TITLE,MESSAGE).
I am trying to search for all the messages send to a certain user . user will enter his name in the Search_textBox ...
0
votes
1
answer
472
views
Login IF statement , the else always getting displayed, possible wrong written script
I always get the "else", even though I add the correct username and password
Photo with the script
private void button1_Click(object sender, EventArgs e)
{
SqlConnection con = new ...
0
votes
2
answers
206
views
Trouble inserting values into SQL table, values get mistaken for columns
I keep getting an exception that reads:
"Invalid Column Name, 'IBM'."
The error is happening at: "' + @ticker + '" even though @ticker is declared in VALUES. I suspect the error ...
0
votes
1
answer
178
views
Writing this C# function in T-SQL
This is part of the code that decompresses BLOB file (removing first 4 binary number from a varbinary column):
In C#:
Stream bStream = sqlBytes.Stream;
byte[] bytes = new byte[bStream.Length];
...