SQL Server is a relational database management system from Microsoft. Use this tag for all SQL Server editions including Compact, Express, Azure, FastTrack and PDW.
0
votes
2answers
10 views
How to copy varchar column with currency value to decimal in SQL Server?
I have a table with around 20K rows of data. One varchar column contains currency info in the format $xxx,xxx,xxx.00. I'd like to create an additional column that is of type decimal and copy the ...
0
votes
0answers
13 views
Sql Cursor…not adding data into the temporary created table
I have the below cursor. It generates the right set of statements but I am not able to insert the data into the temporary created table. The cursor is as below. Please have a look.
--use a cursor to ...
1
vote
1answer
13 views
SQL Server ANDs and ORs precedence
I'm debugging some code and came across this. Could someone help me by putting parens around this statement according to SQL Server ordering. Is it just me, or is this bad coding?
WHERE
T1.C1 = ...
0
votes
1answer
19 views
TSQL update check if null
I have a sql that keep give me an exception, and i can not figure out why, my quess is that the avg(x.Points) return null for some reason, how can i make it return 0 in that case?
UPDATE a
SET ...
0
votes
0answers
27 views
SQL- Selecting Columns based on Date and Batch Number
I am using Chartrunner Lean to produce graphs based on Batch number and Run Date. In the data base there are multiple columns. There are two different sides of the plant which produce data and they ...
-4
votes
1answer
23 views
How to assign global path of database in sqlconnection c# website
SqlConnection cn = new SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\Users\\MANTHAN\\Documents\\Visual Studio 2010\\WebSites\\sample\\App_Data\\Database.mdf;Integrated ...
0
votes
1answer
17 views
Outer Join Or special Union
I have a special kind of Union to implement here, suppose R1 union R2, both table R can be split into 2 part, R.A part which is the content to be union and R.P part which is just a number.
So my ...
0
votes
1answer
49 views
too slow sql server select statement
I have sql server table Bookchapter with about ~ 140.000 rows, FullContent field is nvarchar (max) with long content inside.
SELECT COUNT(Id) AS Expr1
FROM dbo.BookChapter
WHERE ...
0
votes
1answer
15 views
find the field name when compare two xml variables in sql?
I have following query to compare two xml variables and find the difference between two:
DECLARE
@oldXML NVARCHAR(MAX)
, @newXML NVARCHAR(MAX)
SELECT
@oldXML = '<root><row ...
0
votes
3answers
21 views
Inner Join with an And Operator and Or Operator SQL
I am looking for a query which has two operator condition, let say, i have 3 columns in table a and table now, i want to see result as if (a.id=b.id or a.cid=b.cid) And (a.site=b.site)
Table a
...
2
votes
0answers
23 views
Need to get attribute name-value pairs for root element only, in T-SQL query
I've created a table-valued function which returns a list of attribute name-value pairs, when fed an XML fragment, based on Ben Davis's excellent response here. It works, but returns a list of all the ...
0
votes
2answers
25 views
SQL Timestamp Subtraction to get number of days
In the code below instead of active age I need to do a calculation with Open_time and the current time.
In other words i need to do if current time minus open_time is between 0 and 30, or 31 and 60, ...
0
votes
1answer
12 views
SQL Server Update from CheckBoxList VB.Net
I'm running a Survey-like website.
On the admin area of the website, I have the following layout:
The GridView gets the information from tableSurveryQuestion. Each one of the possible answer ...
0
votes
2answers
41 views
Connect To Proper Remote SQL server
On our development server we have three versions of SQL Server installed (SQLEXPRESS 08, SQL2008 R2, and SQL 2012).
In the services, I can see the following instances:
SQL Server (MSSQLSERVER)
SQL ...
0
votes
0answers
4 views
Sybase jtds driver trying to connect to sql server
I have a scenario where user provides me with hostname, port and credentials for the database he wants to connect to. I do not know the flavor of the database though. So what I try to do is try ...