sql-server-2008-r2

Accessing multiple databases from SQL Server 2008 R2 in my windows application [closed]

旧巷老猫 提交于 2019-12-13 09:46:57
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 6 years ago . How to access multiple databases from SQL Server 2008 R2 in my windows application? i want to access multible databases from single sqlserver in my windows application.For ex:i want to select student details from

T-SQL (Un)Pivot Table

流过昼夜 提交于 2019-12-13 09:45:30
问题 I have a view as follows (did a view as I thought it would be easier that accessing the more complicated table) ID | aText1 | aText2 | aInt1 | aInt2 ------------------------------------- 1 | ABC1 | XYZ1 | 2 | 20 2 | ABC1 | XYZ2 | 3 | 25 3 | ABC2 | XYZ2 | 1 | 30 4 | ABC2 | XYZ1 | 4 | 35 I need the result to read | XYZ1 | XYZ2 aText1 | aInt1 | aInt2 | aInt1 | aInt2 --------------------------------------- ABC1 | 2 | 20 | 3 | 25 ABC2 | 1 | 30 | 4 | 35 I've tried various pivots but all fail.

Concatenate Rows for one column SQL [duplicate]

醉酒当歌 提交于 2019-12-13 08:41:39
问题 This question already has answers here : How to use GROUP BY to concatenate strings in SQL Server? (17 answers) Closed 6 years ago . I am using following query to extract appointment data: SELECT app.subject, AL.locationName FROM FilteredAppointment app INNER JOIN appointmentlocation AL ON app.activityid = AL.appointment WHERE app.scheduledstart='2013-07-06 15:00:00.000' The output is as follows with 2 rows (same appointment with two different locations): How can i modify this query to

Update table in SQL Server from two comma separated string parameter [duplicate]

▼魔方 西西 提交于 2019-12-13 08:18:46
问题 This question already has answers here : Closed 6 years ago . Possible Duplicate: Update a table from two comma separated parameter as input I have a Gridview in front end where Grid have two columns : ID and Order like this: ID Order 1 2 2 4 3 1 4 3 Order column is editable. Now if I want to update the order and make save I want to store it into database. I have stored ID and Order as a comma separated string like sID(1,2,3,4) and sOrder(2,4,1,3) and sent to SQL Server as input parameters.

Export contents of SQL Server 2008 R2 table to CSV WITHOUT xp_cmdshell

情到浓时终转凉″ 提交于 2019-12-13 07:21:23
问题 I need to export the contents of a SQL SErver 2008 R2 Express table to a CSV or TXT file. I cannot enable xp_cmdshell nor can I allow ad hoc distributed queries. It needs to be executable from a trigger on one of the tables. 回答1: USE master; GO EXEC sp_configure 'show advanced option', '1'; RECONFIGURE; EXEC sp_configure; EXEC sp_configure 'Ad Hoc Distributed Queries', '1'; RECONFIGURE; EXEC sp_configure; INSERT INTO OPENROWSET('Microsoft.Jet.OLEDB.4.0', 'Text;Database=C:\Temp\;HDR=Yes;',

Incorrect syntax near '<'

房东的猫 提交于 2019-12-13 06:48:57
问题 I have a task to get some code which is working correctly on SQL Server 2012 to work on SQL Server 2008 R2 as well. I got this error: Additional information: Incorrect syntax near '<' When I try to run my code I found out that something is wrong in this line of my SQL code ALTER TABLE [dbo].[WorkTimeEntries] ADD [TimeFinishedForRuntime] AS ISNULL([TimeFinished], IIF ([TimeStarted] < SYSUTCDATETIME(), [dbo].[udf_GetCurrentDateTimeOffsetInTimeZone](DATENAME(TZOFFSET, [TimeStarted])),

How I can insert JSON web service data into a SQL table using SQL query?

旧时模样 提交于 2019-12-13 05:39:14
问题 my link is: http://emkan.bstc.ir:8082/bstco/emkan/mgmt/server/index.php?road=webapi/testwebservice/getDataEmkan&Date1=13961210&Date2=13961210&Hour1=0&Hour2=0&usr=movalled&pwd=123456&pulist=3,17366,17368,17370,17364,17372,17374,17378,17377,17379,17380,17381,17382,17392,17394,17396,17388,17390,17409,17411,17413,17405,17407,&ctpt=2 I want to retrieve data from webservice , then , insert it into a SQL table. 回答1: This is a very poor question... SQL-Server is not the tool to read the JSON from the

Using a string where clause with PredicateBuilder in LinqPad for creating dynamic where clause

家住魔仙堡 提交于 2019-12-13 05:24:16
问题 I am trying to create a dynamic query in LinqPad with PredicateBuilder enabled. I first create a string that corresponds to the where clause for a query like '(orderid >100 AND customerid<=100)' and then try to use this string in building a LINQ query with PredicateBuilder. The dynamic query is represented by the variable 'dynamicResult' in code give at end of this post. The query is on Orders table of Northwind database in SQL Server 2008 R2. The query throws this error in LinqPad, when I

Conditional WHERE clause for fetching records

爷,独闯天下 提交于 2019-12-13 05:23:11
问题 I am using SQL Server 2008 R2. I am having an SQL block as below : DECLARE @Day INT = 5 DECLARE @Month INT = NULL DECLARE @year INT = NULL DECLARE @dtnow DATETIME SET @dtnow = GETDATE() IF @Month IS NULL SELECT @Month = MONTH(DATEADD(MONTH,-1, @dtnow )) IF @Year IS NULL SELECT @year = YEAR(DATEADD(MONTH,-1, @dtnow )) SELECT * FROM TblSalesRecords WHERE CASE WHEN @Day IS NULL THEN -- Condition One BEGIN ISNULL(@Month, MONTH(TblSalesRecords.CreatedDate)) = MONTH(TblSalesRecords.CreatedDate) AND

Character Set issue using SQL Server and ODBC in php

馋奶兔 提交于 2019-12-13 04:56:52
问题 I connected to to sqlsever2008 with odbc(with dsn) and php but problem is that when I retrieve information from that it has character like ��������� . My datatype in sqlserver is nvarchar . Any idea why it is happening? NOTE: The page is utf8 . Edit: I use echo utf8_encode(odbc_result($this->result,'name') ); and characters are like: ÂãæÒÔ ÒÈÇäÂãæÒ i retrieve information like this: odbc_result($this->result,'name') 回答1: Try to use utf8_decode() or utf8_encode() . 回答2: It seems, the code page