sql-server

Insert converted varchar into datetime sql

帅比萌擦擦* 提交于 2021-02-20 19:53:51
问题 I need to insert a varchar in my table. The type in the table is a datetime so I need to convert it. I didn't think this would be to big of a problem however it keeps inserting 1900-01-01 00:00:00.000 instead of the date I want. When I do a select with my converted date it does show me the correct date. I'll show you the code: INSERT INTO Item (CategoryId, [Date], Content, CreatedOn) SELECT CategoryId, Convert(datetime, '28/11/2012', 103), Content, GetDate() FROM Item i JOIN Category c ON i

Change SQL Server database version

老子叫甜甜 提交于 2021-02-20 19:51:14
问题 I have a SQL Server 2008 version database (version number 655). If I try to create for attach it to a SQL Server 2005 or SQL Server 2000, I get an error: This database is version 655. This server is compatible with version 612 or previous Of course I can attach the database to SQL Server 2008 without errors. I know I can generate SQL commands for the structure, but there is a lot of data also in many tables. If I can change the internal database version (the compatibility level is now set to

Insert converted varchar into datetime sql

大憨熊 提交于 2021-02-20 19:51:09
问题 I need to insert a varchar in my table. The type in the table is a datetime so I need to convert it. I didn't think this would be to big of a problem however it keeps inserting 1900-01-01 00:00:00.000 instead of the date I want. When I do a select with my converted date it does show me the correct date. I'll show you the code: INSERT INTO Item (CategoryId, [Date], Content, CreatedOn) SELECT CategoryId, Convert(datetime, '28/11/2012', 103), Content, GetDate() FROM Item i JOIN Category c ON i

SQLBindParameter and SQLExecute returns SQL_NEED_DATA

不打扰是莪最后的温柔 提交于 2021-02-20 19:08:31
问题 I'm working on a C application that interacts with a mssql database running on Windows 2008 R2. I'm able to connect to the database and run specific queries, but when i use SQLBindParameter things fall apart. I found a post on stackoverflow that appears to be the same problem, but the solution doesnt appear to be the same (Problems getting SQLBindParameter to work in C++). According to C Data types SQL_C_CHAR is correct (https://msdn.microsoft.com/en-us/library/windows/desktop/ms714556(v=vs

SQLBindParameter and SQLExecute returns SQL_NEED_DATA

扶醉桌前 提交于 2021-02-20 19:08:29
问题 I'm working on a C application that interacts with a mssql database running on Windows 2008 R2. I'm able to connect to the database and run specific queries, but when i use SQLBindParameter things fall apart. I found a post on stackoverflow that appears to be the same problem, but the solution doesnt appear to be the same (Problems getting SQLBindParameter to work in C++). According to C Data types SQL_C_CHAR is correct (https://msdn.microsoft.com/en-us/library/windows/desktop/ms714556(v=vs

SQLBindParameter and SQLExecute returns SQL_NEED_DATA

我只是一个虾纸丫 提交于 2021-02-20 19:07:53
问题 I'm working on a C application that interacts with a mssql database running on Windows 2008 R2. I'm able to connect to the database and run specific queries, but when i use SQLBindParameter things fall apart. I found a post on stackoverflow that appears to be the same problem, but the solution doesnt appear to be the same (Problems getting SQLBindParameter to work in C++). According to C Data types SQL_C_CHAR is correct (https://msdn.microsoft.com/en-us/library/windows/desktop/ms714556(v=vs

How to add rank column?

≡放荡痞女 提交于 2021-02-20 18:56:34
问题 I would like to select records and determine rank number for each similar data. My data is as follows. MEMBER ID | LOAN AMOUNT 1 | 2,000.00 2 | 1,000.00 3 | 4,000.00 4 | 1,000.00 The result I wanted is shown below. RANK|MEMBER ID|LOAN AMOUNT 1 |3 |4,000.00 2 |1 |2,000.00 3 |2 |1,000.00 3 |4 |1,000.00 RANK is a new column. I am using MS SQL server 2008 and created a view table as shown below but it does not resulting to what is wanted. select rank=count(*), s1.MemberID, s1.Loan_Amount from

T-SQL - string concatenation

筅森魡賤 提交于 2021-02-20 18:54:40
问题 Hope someone can help - I am a novice SQL hacker (and very bad at it indeed!) I have two tables on SQL Server 2005 TABLE 1 and TABLE2: TABLE1 COL1 COL2 1 10 2 20 3 30 4 10 4 20 5 20 6 30 7 10 7 20 TABLE2 COL1 COL2 10 A 20 B 30 C COL2 in TABLE2 is a character representation of the numerical data in COL2 TABLE1. I hope this is understandable? I have worked out how to select COL1 and COL2 from TABLE1 and concatenate the results to show this: COL1 COL2Concat 1 10 2 20 3 30 4 10, 20 5 20 6 30 7 10

T-SQL - string concatenation

混江龙づ霸主 提交于 2021-02-20 18:53:50
问题 Hope someone can help - I am a novice SQL hacker (and very bad at it indeed!) I have two tables on SQL Server 2005 TABLE 1 and TABLE2: TABLE1 COL1 COL2 1 10 2 20 3 30 4 10 4 20 5 20 6 30 7 10 7 20 TABLE2 COL1 COL2 10 A 20 B 30 C COL2 in TABLE2 is a character representation of the numerical data in COL2 TABLE1. I hope this is understandable? I have worked out how to select COL1 and COL2 from TABLE1 and concatenate the results to show this: COL1 COL2Concat 1 10 2 20 3 30 4 10, 20 5 20 6 30 7 10

Having trouble creating a view in Microsoft SQL Server Management Studio

半腔热情 提交于 2021-02-20 18:53:32
问题 I'm new to sql and am struggling to make a view. This works and pulls in the correct data I need as a table, but when I try it as a view I get the error: SQL text cannot be represented in the grid pane and diagram pane. SELECT [Data_Collector_ID], [Batch_Info_ID], [AssetTag], [DateTimeStamp], [Dust_Collector_DP] FROM ( SELECT [Data_Collector_ID], [Batch_Info_ID], [AssetTag], [DateTimeStamp], [Dust_Collector_DP], ROW_NUMBER() OVER (PARTITION BY [Batch_Info_ID] ORDER BY [DateTimeStamp] DESC) rn