sql-server-2012

How to parse json data in SQL Server 2012?

和自甴很熟 提交于 2019-12-25 06:08:24
问题 I am using SQL Server 2012.I have been assigned a task where one of my column ( JsonText ) of table Sample contains json data. I want to pass parse that data and insert into columns of another table ( Test ). I searched on net 'openjson' is supported in SQL Server 2016. How to do in SQL Server 2012? Table1 : Sample Id JsonText Active JsonText webaddress?{'data':'{"PId": "XXXX","Status": "YES","Name":"XXX","Address":"XXXX","MobileNumber":"xxx"}'} I am intrested only 'PID,Address,MobileNumber'

Microsoft SQL Server Error: 18456 + windows authentication

删除回忆录丶 提交于 2019-12-25 06:04:04
问题 My PC name is IBALL1 . I get an error Login Failed for user 'iball1\User1'.(Microsoft SQL server, Error: 18456) I am trying to log in using Windows authentication. And in SQL Server Configuration Manager > SQl Server Service > SQL Server Logon As Local System. In error log text file, at C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\Log Log says: Login failed for user 'iball1\User1'. Reason: Could not find a login matching the name provided. [CLIENT: local machine] 回答1: i

Microsoft SQL Server Error: 18456 + windows authentication

百般思念 提交于 2019-12-25 06:04:00
问题 My PC name is IBALL1 . I get an error Login Failed for user 'iball1\User1'.(Microsoft SQL server, Error: 18456) I am trying to log in using Windows authentication. And in SQL Server Configuration Manager > SQl Server Service > SQL Server Logon As Local System. In error log text file, at C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\Log Log says: Login failed for user 'iball1\User1'. Reason: Could not find a login matching the name provided. [CLIENT: local machine] 回答1: i

Microsoft SQL Server Error: 18456 + windows authentication

99封情书 提交于 2019-12-25 06:03:10
问题 My PC name is IBALL1 . I get an error Login Failed for user 'iball1\User1'.(Microsoft SQL server, Error: 18456) I am trying to log in using Windows authentication. And in SQL Server Configuration Manager > SQl Server Service > SQL Server Logon As Local System. In error log text file, at C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\Log Log says: Login failed for user 'iball1\User1'. Reason: Could not find a login matching the name provided. [CLIENT: local machine] 回答1: i

sumProduct in sql

天涯浪子 提交于 2019-12-25 05:48:07
问题 I'm trying implementing sumproduct (from excel) in my table on the server. select * into #myTable2 from #myTable1 select a, b, c, d, e, ( select (c * e)/100*3423) from #myTable1 t1 inner join #myTable t2 on t1.b = t2.b where b like 'axr%' ) as sumProduct from #myTable1 but this doesn't quite work. Can't spot the error, maybe i'm just tired or missing it. edit: sample data and desired results will mention only the important columns c e b a sumProduct 2 4 axr1 2012.03.01 2*4 + 3*8 3 8 axr3 2012

Conditional transaction rollback

↘锁芯ラ 提交于 2019-12-25 05:33:42
问题 I am wondering, if there is a possibility to apply conditional transaction rollback based on state of particular batch. For example, I have a following code: BEGIN TRAN --EXEC No 1 EXEC [dbo].[MyProc] 1; GO --EXEC No 2 EXEC [dbo].[MyProc] 22; GO --EXEC No 3 EXEC [dbo].[MyProc] 333; GO --EXEC No 4 EXEC [dbo].[MyProc] 5; GO COMMIT And I want to rollback entire transaction if the EXEC No 3 fails. If any other execution fails I want SQL Server to continue executing my query. Is it possible? 回答1:

check if id exists in multiple tables

こ雲淡風輕ζ 提交于 2019-12-25 05:33:27
问题 I am using SQL Server 2012. I have 5 tables (lets call them A, B, C, D & E). Each table contains a column called m_id, which contains id's that are nvarchar(10). I currently run the query below 5 times (changing the table name). To see if the table contains the id. select m_id from A where m_id = 'some_id' Basically I want to know if the id is any of the 5 tables, if so return 1 else if does not exist in any of the 5 tables return 0. I feel the current way I'm doing this is very inefficient.

check if id exists in multiple tables

北战南征 提交于 2019-12-25 05:33:06
问题 I am using SQL Server 2012. I have 5 tables (lets call them A, B, C, D & E). Each table contains a column called m_id, which contains id's that are nvarchar(10). I currently run the query below 5 times (changing the table name). To see if the table contains the id. select m_id from A where m_id = 'some_id' Basically I want to know if the id is any of the 5 tables, if so return 1 else if does not exist in any of the 5 tables return 0. I feel the current way I'm doing this is very inefficient.

GridView footer not displaying data

左心房为你撑大大i 提交于 2019-12-25 04:56:26
问题 I'm using ASP.NET (VB.NET) with SQL-Server-2012. I'm using a GridView to display data in table called project_items . I added a FooterTemplate so that I could display the total amount of all the records in a column. This is what I did: <asp:GridView ID="grdItems" runat="server" AutoGenerateColumns="False" CellPadding="4" Font-Names="Tahoma" ForeColor="#333333" GridLines="None" ShowFooter="True"> <AlternatingRowStyle BackColor="White" ForeColor="#284775" /> <Columns> <asp:BoundField DataField=

Automate execution of multiple SQL Server 2012 scripts in specific order

天大地大妈咪最大 提交于 2019-12-25 04:45:18
问题 I needed some guidance with a task I have never worked with SQL Server 2012. Your help would be very much appreciated. I have inherited a data model in SQL Server. Basically, I have 5 SQL scripts: Script A Script B Script C Script D Script E For running successfully script B,it needs access to tables generated by script A to perform calculation. Basically, the scripts are feeding each other. I need to run the scripts in a specific order. My first idea was "stored procedure". So far, I have in