sql-server-2005

Preserving format while passing DateTime values to Stored Procedure

£可爱£侵袭症+ 提交于 2019-12-25 02:08:28
问题 I have a TextBox server control on a Web Form, say, txtDueDate . I don't want to use DateTimePicker but want to use TextBox itself. The user enters date in dd/mm/yyyy format. While passing this value to SQL Server 2005 (Express) stored procedure, I use something like: cmdParameters.AddWithValue("@DueDate", Convert.ToDateTime(txtDueDate.Text)); The stored procedure has input parameter to handle this value and is declared as: @DueDate SmallDateTime I want to know the default format SQL Server

How do I create a datetime from a custom format string?

血红的双手。 提交于 2019-12-25 01:48:47
问题 I have datetime values stored in a field as strings. They are stored as strings because that's how they come across the wire and the raw values are used in other places. For reporting, I want to convert the custom format string (yyyymmddhhmm) to a datetime field in a view. My reports will use the view and work with real datetime values. This will make queries involving date ranges much easier. How do I perform this conversion? I created the view but can't find a way to convert the string to a

How can i solve “An explicit value for the identity column in table”?

寵の児 提交于 2019-12-25 01:45:47
问题 if i try to add some data into my table error occurs: Error:Msg 8101, Level 16, State 1, Line 1 An explicit value for the identity column in table 'ENG_PREP' can only be specified when a column list is used and IDENTITY_INSERT is ON. insert into ENG_PREP VALUES('572012-01-1,572012-01-2,572012-01-3,572013-01-1,572013-01-2', '', '500', '', 'A320 P.001-A', 'Removal of the LH Wing Safety Rope', '', '', '', '0', '', 'AF', '12-00-00-081-001', '', '', '', '', '', '', '' ) 回答1: If you must write to

Rows to Columns SQL Server

雨燕双飞 提交于 2019-12-25 01:39:20
问题 I am currently trying to convert a table of rows into a view of columns in an MS SQL Database. My data is currently in a table like so: ID OID Field DataType Value Archived == === ==================================== ======== ===== ========= 1 13 E21FC1EC-A6D9-43E2-8C8E-0F2935A7EF68 string Hello 0 2 13 6BBDE7FA-6F7A-4319-899B-2DF0E6610FA9 string World 1 3 13 91BB8616-43CD-48EC-97CD-5813B67770ED int 1 0 4 13 A98D43C3-0A9C-4173-8ECE-29AAAE1D973E int 2 1 5 13 92BB0DFF-EEAF-4A07-A65A-C3A1E1220F60

Easiest way to find IsManager in SQL

早过忘川 提交于 2019-12-25 01:27:33
问题 Simple structure table of employees Employee Manager Joe Smith Jon Smith Jon Smith Pete Stevens Pete Stevens NULL Jared Scho Pete Stevens .... Im just trying to return some results but I want an indicator on whether the person is a manager or not so the result should be: Employee Manager IsAManager Joe Smith Jon Smith 0 Jon Smith Pete Stevens 1 Pete Stevens NULL 1 Jared Scho Pete Stevens 0 The result set is showing that Joe Smith and Jared Scho are not managers... So If I had a simple SQL

insert muliple records on single click on button dynamically

你说的曾经没有我的故事 提交于 2019-12-25 00:38:03
问题 i have 2 tables like.... Here Admin Assigns Subjects to faculties as per course and semester.... 1] Assign_Subjects Faculty_Id varchar(20) Course_Id varchar(20) Semester varchar(20) Subject_Id varchar(20) Subject_Name varchar(50) Time varchar(50) INSERT INTO Assign_Subjects Values("F1","BCA",2,"DS","Data Structure","10-11") INSERT INTO Assign_Subjects Values("F1","BCA",2,"C","C Programming","11-12") INSERT INTO Assign_Subjects Values("F1","BCA",1,"QB","Q Basic","1-2") INSERT INTO Assign

Getting ParsingError, InvalidSoapActionHeader on SQL Server SOAP request

拈花ヽ惹草 提交于 2019-12-25 00:36:18
问题 I am attempting to send a SOAP request to SQL Server 2005, but I am getting a vague error in response. Can anyone interpret for me? Here is my request (linebreaks have been added for readability): <v:Envelope xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:d="http://www.w3.org/2001/XMLSchema" xmlns:c="http://www.w3.org/2001/12/soap-encoding" xmlns:v="http://www.w3.org/2001/12/soap-envelope"> <v:Header> <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401

How to create a column of a specific type?

独自空忆成欢 提交于 2019-12-25 00:09:59
问题 How would I add a column to a Select and have that column be of a specific type. For example Select Company, City, Dues, 0 As NewColumn1, 123.12 As NewColumn2 But I want NewColumn1 to be of type bit, and NewColumn2 to be of type Real Oh, I'm using SQL Server 2005. 回答1: You can use CAST Select Company, City, Dues, CAST(0 AS BIT) As NewColumn1, CAST(123.12 AS REAL As NewColumn2 FROM @Table Have a look at CAST and CONVERT (Transact-SQL) . 来源: https://stackoverflow.com/questions/1920086/how-to

How can you use SQL to return values for a specified date or closest date < specified date?

南楼画角 提交于 2019-12-25 00:06:30
问题 I've written an SQL statement to return a list of prices based on a date parameter, but I am finding that on some dates, the price is missing. I am looking for a way to modify this statement to return the price on the date specified, but if that is not available return the price for the most recent price available before the date specified. Select date, grp, id, price From price_table Where date In ('12/31/2009', '11/30/2009') And grp In ('Group1') For example, in the I would like to be able

For xml type generating null element tags in sql server 2005 express 2005

本秂侑毒 提交于 2019-12-24 23:47:40
问题 Hi i tried the below but it doesn't generate xml element for empty/null values. Could someone point me the mistake i am making. Xml Output i expect <Board> <BoardId>1</BoardId> <Title>Introduction to modal popup control</Title> <Desc>The ModalPopup extender allows you to display content in an element that</Desc> </Board> <Comment> <CommentId>1</CommentId> <Comment>Typing a comment and sending it is such a neat stuff</Comment> <Date>2011-03-25T15:24:43</Date> </Comment> <Comment> <CommentId>2<