ssms

SQL Query Compare values in per 15 minutes and display the result per hour

£可爱£侵袭症+ 提交于 2019-12-02 08:52:14
问题 I have a table with 2 columns. UTCTime and Values. The UTCTime is in 15 mins increment. I want a query that would compare the value to the previous value in one hour span and display a value between 0 and 4 depends on if the values are constant. In other words there is an entry for every 15 minute increment and the value can be constant so I just need to check each value to the previous one per hour. For example +---------|-------+ | UTCTime | Value | ------------------| | 12:00 | 18.2 | | 12

SQL Azure: SMO Exception when scripting objects in SSMS 2008 R2

冷暖自知 提交于 2019-12-02 08:33:35
问题 I am using SQL Server Management Studio 2008 R2 to manage a SQL Azure database. When I try to right-click on any of the objects in the database, and do Script Table As -> CREATE -> New Query Editor Window, I get the following exception screen every time: Scripting for SELECT -> New Query Editor Window is the only option that seems to work without generating an Exception like above. Any ideas?? 回答1: Here are additional details about this issue. Latest service update for SSMS: http://support

SQL Query Compare values in per 15 minutes and display the result per hour

我怕爱的太早我们不能终老 提交于 2019-12-02 08:18:54
I have a table with 2 columns. UTCTime and Values. The UTCTime is in 15 mins increment. I want a query that would compare the value to the previous value in one hour span and display a value between 0 and 4 depends on if the values are constant. In other words there is an entry for every 15 minute increment and the value can be constant so I just need to check each value to the previous one per hour. For example +---------|-------+ | UTCTime | Value | ------------------| | 12:00 | 18.2 | | 12:15 | 87.3 | | 12:30 | 55.91 | | 12:45 | 55.91 | | 1:00 | 37.3 | | 1:15 | 47.3 | | 1:30 | 47.3 | | 1:45

Splitting of comma separated values [duplicate]

杀马特。学长 韩版系。学妹 提交于 2019-12-02 07:16:19
This question already has an answer here: T-SQL: Opposite to string concatenation - how to split string into multiple records [duplicate] 11 answers I have some columns with comma-separated values. For example A as,ad,af,ag My manager wants the output looks like this: A as ad af ag All these should come under one row. I guess we need to use something line break. Hi can we use replace with char(13)+char(10) something. This one also works... Thanks, Shashra You can create a user defined UDF like the one shown below. Then, just pass in the comma separated list from another query and it will

Database created in SQL Server Management Studios cannot be found by Visual Studio 2010

早过忘川 提交于 2019-12-02 06:40:22
问题 I created a new database ( AC_2012 ) on my localhost in SQL Server 2008 Management Studio. I'm trying to connect it via connection string in web.config in Visual Studio 2010 Premium. It won't pick it up. <configuration> <configSections> <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.3.1.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> </configSections> <system.web> <compilation debug="true" targetFramework

Restored database missing views, stored procs and foreign keys

房东的猫 提交于 2019-12-02 05:24:55
问题 I'm trying to create a copy of a database in SQL Management Studio (SQL Server Express) using Backup-Restore. Local to local. When I do it it copies tables and data, but ignores views, stored procedures and foreign keys. Object Explorer -> write-click "Databases" -> "Restore Database..." -> put in a name -> select a "from" database -> go This is the script that gets generated: RESTORE DATABASE [DbName_raw] FROM DISK = N'C:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\Backup

Microsoft Sql Server Managment studio backup size goes negative

[亡魂溺海] 提交于 2019-12-02 05:23:00
The problem is that I need to explain the different sizes of backups that are being made of a database in a plant. Sometimes the difference between the sizes is in negative, even though that there is no data being deleted from the system. Datum Backupfile-file Size KB Diff 6/1/10 backup201006010100.bak 3355914 7/1/10 backup201007010100.bak 4333367 977453 7/2/10 backup201007020100.bak 4355963 22596 7/3/10 backup201007030100.bak 4380896 24933 7/4/10 backup201007040100.bak 4380404 -492 8/1/10 backup201008010100.bak 4507775 1151861 8/2/10 backup201008020100.bak 4507777 2 8/3/10 backup201008030100

Keyboard shortcut to automatically wrap selected text in IsNull([text], 0) in SSMS

泄露秘密 提交于 2019-12-02 04:21:13
Is there some way to have a shortcut in SQL Server Management Studio (SSMS) that when text is selected, it wraps that text in an IsNull() statement? For example, I highlight the text below: My_column_name and when I click the keyboard shortcut, what was highlighted turns into: IsNull(My_column_name, 0) I am using SSMS v17.4 You can get this done using snippets. It's not exactly a simple shortcut, but a few keystrokes will get you there. First you need to create a snippet like this: <?xml version="1.0" encoding="utf-8" ?> <CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005

SQL Azure: SMO Exception when scripting objects in SSMS 2008 R2

a 夏天 提交于 2019-12-02 03:53:22
I am using SQL Server Management Studio 2008 R2 to manage a SQL Azure database. When I try to right-click on any of the objects in the database, and do Script Table As -> CREATE -> New Query Editor Window, I get the following exception screen every time: Scripting for SELECT -> New Query Editor Window is the only option that seems to work without generating an Exception like above. Any ideas?? Here are additional details about this issue. Latest service update for SSMS: http://support.microsoft.com/kb/2507770 Blog discussing the necessary upgrade: http://social.msdn.microsoft.com/Forums/en-AU

TSQL Query returns values for each hour for the past 24 hours

折月煮酒 提交于 2019-12-02 03:49:33
问题 I have a query that I don't really know how to begin with. I'm hoping someone can help me out with it. I will start by explaining the table I have a device table with four columns: Device_Id, Device_Status, Begin_dt, End_dt there are 6 different statuses where 3 (for simplicity lets say status 1, 4 and 5) mean the device is 'online' an example of this table could be Id | Status| Begin | End 001| 1 | 2012-09-01 00:00:00.000 | 2012-09-01 01:00:00.000 001| 2 | 2012-09-01 01:00:00.000 | 2012-09