In SQL server we can use “isnull” function for example if Table1 Contains Field1 and only one record which Field1 is null we can write this Query: which returns “0”. can we use any function like this in C#? for Example Consider textBox1 is Empty. and I want to Show “0”. Ans…
Tag: sql-server
how to set N prefix before sql parameter
i writed a query like this: SELECT [FirstName], [LastName] FROM [WorkersView] WHERE ([FirstName] LIKE ‘%’ + N’علی’ + ‘%’ ) AND ([LastName] LIKE ‘%’ + N’مسروری’ + ‘%’) and it’s work very well! and …
MS SQL Server – How to create a view from a CTE?
The here above SQL is outputing like a charm all hours between two dates and a field retrieved from a join with another table: I would like to create a view from that but I do not manage to do it. I tried several things but without success. The following is returning : Incorrect syntax near the keyword ‘…
Get previous and next row from rows selected with (WHERE) conditions
For example I have this statement: This statement is splitted by word, like this table: I want to get previous and next word of each word For example I want to get previous and next word of “name”: How could I get this result? Answer you didn’t specify your DBMS, so the following is ANSI SQL…
which gives best performance?
Please go through the following query, and help me to understand which one is efficient and how? In logical query execution, where clause will be executed after completion of join, so I thought the …
Text Qualifier syntax in PDW dwloader
I am using dwloader utility to load data into PDW. My dwloader syntax is given below: I got the data loaded into the table. But all the varchar columns have data within double ‘quotes’. My text file is commma delimited. Any idea on how to include the text qualifier in the above syntax? Answer I fi…
How to get last date of month SQL Server 2008
I created a function “ufngetFirstDateOfMonth” and “ufngetLastDateOfMonth” stored in Microsoft SQL Server 2008. My purpose is to send some date into the function and it will return the first date of …
Escape single quote in sql query c#
Here I have this method in my CandidateOp class file. I’m passing the ComboBox text in the form and I am getting the ID to the integer type variable tempPrID. The partyIDtoInsert, is a stored procedure I have created and it is being called in the method getpartyID as shown before, to get the id of unite…
Default row order in SELECT query – SQL Server 2008 vs SQL 2012
Our team recently upgraded our databases from SQL Server 2008 to SQL Server 2012. One breaking change we noticed was in the default order of rows returned by the SELECT statement, i.e. when an explicit ORDER BY clause is not specified. As per MSDN, SQL Server 2012 does not gaurantee the order of the rows retu…
Creating EVENTS in SQL Server
I want to execute a query at a specific time. In MySQL we use events for that, example is as follows: CREATE EVENT myevent ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 HOUR DO UPDATE …