sql-server-2012

Not able to pass input parameters to stored procedure

随声附和 提交于 2019-12-10 23:39:01
问题 I have store procedure like this getting values from database based upon the search criteria that I am passing those ones are as input parameters to that procedure but I am getting error at @StatusSelection CREATE PROCEDURE [dbo].[tp_SelectTransactionHistorySearch] ( @OffSetRowNo INT, @FetchRowNo INT, @StatusSelection NVARCHAR(MAX), @isReviewed Bit, @ProjectCaseNumber VARCHAR(MAX), @CostPageNumber VARCHAR(MAX), @TransactionTypeChange VARCHAR(MAX), @DescriptionChange VARCHAR(MAX),

Unexpected query results

不羁岁月 提交于 2019-12-10 23:30:15
问题 Why I get following results from sql-server? SELECT '' + 12 C1, CONVERT(int, '') C2, CASE WHEN '' = ' ' THEN 'equal' ELSE 'not equal' END C3 Sql-Server Fiddle demo --Results | C1 | C2 | C3 | ------------------- | 12 | 0 | equal | EDIT: C3 has been answered. Everyone answered thinking '' + 12 = 12 is string concatenation but it is a mathematical operation. It is not clear why ( NOT how) '' is converting to a 0 in sql-server. 回答1: SQL Server has a strange feature whereby, if two strings are

DB column extract and split to find other table result

拈花ヽ惹草 提交于 2019-12-10 23:21:20
问题 I have table1 where Temp_ID column is combination of ID column values form table2 and table3 . Example: table1_id:table2_id {values like (1:1,2:2)} What I do in my Java code I need to use Temp_ID and split according to COLON(:), and then we can get table 2 and table 3 data using ID values obtained from split. But table1 can have huge data, so if i do this in java I need to run 2 queries again and again. Is it possible to write query, So i can do this split of Temp_ID in query and use those to

Error: String or binary data would be truncated. The statement has been terminated

筅森魡賤 提交于 2019-12-10 21:35:06
问题 I'm trying to create a simple registration form, where data from textboxes etc. are input into a table called users : user_id int username nchar(20) password nchar(20) ... more columns Code: Dim Username As String = txtUsername.ToString ... more variable declarations lblDOB.Text = DOB.ToString lblDOB.Visible = True Dim ProjectManager As String = "test" ... more constant declarations Dim conn As New SqlConnection("...conn string...") sqlComm = "INSERT INTO users(Username, Password, ...other

SQL Server 2012 - Case statement in where clause

我的未来我决定 提交于 2019-12-10 21:32:54
问题 SQL is not my strong suit, but I cannot figure out why this isn't working. I simply want to run a different AND statement based on a value. Specifically, I want to change the datePart in the dateDiff function if foo is = 0 SELECT foo, bar, test FROM table WHERE bar = 1, CASE WHEN foo = 0 AND dateDiff(dd, getDate(), 2 ) < test ELSE AND dateDiff(hh, getDate(), 2 ) < test END 回答1: Try this one - SELECT foo, bar, test FROM [table] WHERE bar = 1 AND ( ( foo = 0 AND DATEDIFF(dd, GETDATE(), 2 ) <

How to get results of stored procedure #1 into a temporary table in stored procedure #2

折月煮酒 提交于 2019-12-10 21:24:50
问题 I am trying to combine the results of several stored procedures into a single temporary table. The results of the various stored procedures have the same column structure. Essentially, I would like to UNION ALL the results of the various stored procedures. A significant fact: each of the stored procedures creates a temporary table to store its data and the results each returns are based on a select against the temporary table: create proc SP1 as . . <snip> . select * from #tmp -- a temporary

Building SSIS solution using visual studio online build definition… .dtproj is not supported by MSBuild and cannot be built

ぃ、小莉子 提交于 2019-12-10 20:12:04
问题 I've created a build definition via visual studio online that builds an SSIS project (dtproj). The build appears to succeed but there is a warning that appears stating "dtproj is not supported by MSBuild and cannot be built". SSDT has been installed on the build server. Does anyone have any ideas why this warning would be showing up? 回答1: MSBuild cannot build the project file format that SSDT uses. It is a pre-msbuild visuals studio format. There's a hacky way to create an msbuild project

Is there a way to bind SSMS 2012 keyboard shortcuts to a procedure in a way where I can pass the fully qualified object name?

南楼画角 提交于 2019-12-10 19:59:35
问题 In SSMS 2012, is there any way I can bind a keyboard shortcut (e.g. Ctrl - 5 ) so that I can highlight a qualified object name (e.g. master.sys.objects ) and invoke my own procedure using that object name as the argument? I know that this does work if I explicitly add quotes or brackets around the object name prior to using the keyboard shortcut (e.g. highlight the string 'sys.objects' , but this becomes tedious when wanting to use my shortcut easily by directly highlighting tables in

insert control characters in nvarchar or varchar from SQL script?

落爺英雄遲暮 提交于 2019-12-10 19:56:57
问题 Given SQL Server 2012, how can I insert control characters (the ones coded under ASCII 32, like TAB, CR, LF) in a nvarchar or varchar column from a SQL script? 回答1: Unless I miss something in the question you can do this using TSQL CHAR() function: INSERT INTO MyTable(ColName) VALUES(CHAR(13) + CHAR(10)) Will insert CR/LF. Same for other codes. Edit there is TSQL NCHAR() as well for Unicode characters. 回答2: Please note that the function may vary depending on the type of your column, using the

Getting total values of a certain column from GridView

天大地大妈咪最大 提交于 2019-12-10 19:51:36
问题 Him I am using a ASP.NET/VB.NET with SQL-Server-2012. I have a a GridView column with 3 fields and 1 template field as shown below: <asp:GridView ID="grdItems" runat="server" AutoGenerateColumns="False" CellPadding="4" DataSourceID="SqlDataSource3" Font-Names="Tahoma" ForeColor="#333333" GridLines="None"> <AlternatingRowStyle BackColor="White" ForeColor="#284775" /> <Columns> <asp:BoundField DataField="item_name" HeaderText="Item" SortExpression="item_name" /> <asp:BoundField DataField="item