sql-server-2008-r2

Generate unique 9 digits values

对着背影说爱祢 提交于 2019-12-13 02:46:59
问题 I have a table as shown below: Group --------------------------- Id Num Name Age --------------------------- 1 424000000 Damine 22 2 324000000 Arshley 18 3 276000000 Tita 20 4 424000000 Helen 21 5 424000000 Mary 19 6 324000000 Kathe 20 7 324000000 Mark 18 8 276000000 Phill 22 i want to make the Num col unique so i need to generate 9 digit numeric random values for the duplicates. please help, Thanks 回答1: you set the num column as an identity field with a seed like 100000000 or just set the

SqlDataConnection type provider generates massive error with SQL Server 2008 R2

不想你离开。 提交于 2019-12-13 02:36:28
问题 For some reason, I can't create a type provider for a particular database. I have code which looks a bit like this (not the actual database names, obviously): type db1 = SqlDataConnection<"Data Source=SQL_05;Initial Catalog=**DATABASE1**;Integrated Security=true;MultipleActiveResultSets=True"> type db2 = SqlDataConnection<"Data Source=SQL_08;Initial Catalog=**DATABASE2**;Integrated Security=true;MultipleActiveResultSets=True"> type db3 = SqlDataConnection<"Data Source=SQL_10;Initial Catalog=*

how to combine two Data Columns?

℡╲_俬逩灬. 提交于 2019-12-13 01:40:19
问题 i have this SQL statement I want to combine 'date' and 'dayOfWeek' Column SELECT CONVERT(date,startTimeStamp) AS DATE , datename(dw,CONVERT(date,startTimeStamp)) as dayOfWeek ,CONVERT(time,[startTimeStamp])AS StartTime ,CONVERT(time,[endTimeStamp])AS EndTime ,DATEDIFF(HH,[startTimeStamp] ,[endTimeStamp]) FROM [TaskManagementSystem_DB].[dbo].[Timesheet_entry] 回答1: Sounds like you want this: SELECT CONVERT(date,startTimeStamp) AS DATE , datename(dw,CONVERT(date,startTimeStamp)) as dayOfWeek

comparison query taking ages

旧城冷巷雨未停 提交于 2019-12-13 01:29:16
问题 My query is quite simple: select a.ID, a.adres, a.place, a.postalcode from COMPANIES a, COMPANIES b where a.Postcode = b.Postcode and a.Adres = b.Adres and ( select COUNT(COMPANYID) from USERS where COMPANYID=a.ID )>( select COUNT(COMPANYID) from USERS where COMPANYID=b.ID ) Database: sql server 2008 r2 What I'm trying to do: The table of COMPANIES contains double entries. I want to know the ones that are connected to the most amount of users. So I only have to change the foreign keys of

Pivoting a column and showing data according to count

こ雲淡風輕ζ 提交于 2019-12-13 01:27:13
问题 I have following table: I wanted to pivot month column and show count of data according to groups of >10,<=06,etc. Means wanted to show how many counts for >10 in Jun, jan As folows: Gruppi Min (GG Flusso/Decorrenza-->Out) Jan Feb Mar Apr May Jun >10 5 2 1 0 8 2 <=06 2 8 1 7 9 33 I Tried as follows: SELECT * FROM (SELECT CONVERT(CHAR(3), [data out (no val#vuoto)], 0) month, ( [gruppi min (gg flusso/decorrenza-->out)] ) FROM dbpratiche WHERE compagnia = 'GENERALI INA ASSITALIA' AND stato =

Why can't i backup database using t-sql?

杀马特。学长 韩版系。学妹 提交于 2019-12-13 00:50:56
问题 I try to backup database using code below : backup database RestaurantManagement to disk = 'd:\' sqlserver always show the message below : Msg 3201, Level 16, State 1, Line 3 Cannot open backup device 'd:\'. Operating system error 3(The system cannot find the path specified.). Msg 3013, Level 16, State 1, Line 3 BACKUP DATABASE is terminating abnormally. How can i code it ? help... 回答1: You need to provide the backup file name, like this: backup database RestaurantManagement to disk = 'd:

Generate scripts with new ids (also for dependencies)

旧巷老猫 提交于 2019-12-13 00:36:49
问题 In Microsoft SQL Server 2008 R2 I have some data stored in a table for which I want a script which creates an exact copy of the data, with different guids's (uniqueidentifiers) only. The challenge is, there is also data in other tables with dependencies on the main table. These data should also be copied and referenced to the new entries. The structure looks like that: Table Form: Guid Name 335AC2DD-C874-45E4-90AA-194882DB7C12 Testform Table Field: Guid FormGuid Name 9640CA20-2CE6-4BFB-929C

Microsoft SQL Server 2008 R2 Setup MOF compiler could not connect with the WMI server

爷,独闯天下 提交于 2019-12-12 20:52:50
问题 I have installed visual studio 2010 on my Inspiron 1464 64 bit processor which has windows 7 professional installed. I tried to install sql server 2008 r2 express edition with tools version 10.50.1600.1 from microsoft. But i am unable to install it i have got the following error in the middle of the installed and it closed. TITLE: Microsoft SQL Server 2008 R2 Setup The following error has occurred: The MOF compiler could not connect with the WMI server. This is either because of a semantic

Externally activate non-.NET application from Service Broker

泪湿孤枕 提交于 2019-12-12 20:48:54
问题 Can you externally activate a non-.NET app like Java or Python as easily you can a .NET app from Service Broker? Are there any issues / concerns with doing this? 回答1: The external activation logic should apply in the same way. Once you have an sql server connection, everything is handled in t-sql and service broker objects. Event-Based Activation 来源: https://stackoverflow.com/questions/10163073/externally-activate-non-net-application-from-service-broker

Arithmetic overflow error converting expression to data type datetime (Int64 to datetime)

China☆狼群 提交于 2019-12-12 19:22:06
问题 Trying SELECT convert(datetime, 20120825142616 , 120) AS time Running into exception Arithmetic overflow error converting expression to data type datetime. The value '20120825142616 ' is of type 'Int64 ' passed as parameter to a .Net SqlCommand object. Any help is appreciated 回答1: If you place your data in single quote then you will not get arithmetic flow error SELECT convert(datetime, '20120825142616' , 120) AS [time] but you will got an error: Conversion failed when converting date and/or