sql-server-2005

Convert Xml to Table SQL Server

☆樱花仙子☆ 提交于 2020-01-08 15:50:24
问题 I wonder how can i read a xml data and transform it to a table in TSQL? For example: <row> <IdInvernadero>8</IdInvernadero> <IdProducto>3</IdProducto> <IdCaracteristica1>8</IdCaracteristica1> <IdCaracteristica2>8</IdCaracteristica2> <Cantidad>25</Cantidad> <Folio>4568457</Folio> </row> <row> <IdInvernadero>3</IdInvernadero> <IdProducto>3</IdProducto> <IdCaracteristica1>1</IdCaracteristica1> <IdCaracteristica2>2</IdCaracteristica2> <Cantidad>72</Cantidad> <Folio>4568457</Folio> </row> To 8 3 8

Convert Xml to Table SQL Server

房东的猫 提交于 2020-01-08 15:50:08
问题 I wonder how can i read a xml data and transform it to a table in TSQL? For example: <row> <IdInvernadero>8</IdInvernadero> <IdProducto>3</IdProducto> <IdCaracteristica1>8</IdCaracteristica1> <IdCaracteristica2>8</IdCaracteristica2> <Cantidad>25</Cantidad> <Folio>4568457</Folio> </row> <row> <IdInvernadero>3</IdInvernadero> <IdProducto>3</IdProducto> <IdCaracteristica1>1</IdCaracteristica1> <IdCaracteristica2>2</IdCaracteristica2> <Cantidad>72</Cantidad> <Folio>4568457</Folio> </row> To 8 3 8

How to print VARCHAR(MAX) using Print Statement?

情到浓时终转凉″ 提交于 2020-01-08 15:46:43
问题 I have a code which is: DECLARE @Script VARCHAR(MAX) SELECT @Script = definition FROM manged.sys.all_sql_modules sq where sq.object_id = (SELECT object_id from managed.sys.objects Where type = 'P' and Name = 'usp_gen_data') Declare @Pos int SELECT @pos=CHARINDEX(CHAR(13)+CHAR(10),@script,7500) PRINT SUBSTRING(@Script,1,@Pos) PRINT SUBSTRING(@script,@pos,8000) The length of the Script is around 10,000 Characters and Since I am using print Statement which can hold only max of 8000. So I am

How to print VARCHAR(MAX) using Print Statement?

旧街凉风 提交于 2020-01-08 15:45:06
问题 I have a code which is: DECLARE @Script VARCHAR(MAX) SELECT @Script = definition FROM manged.sys.all_sql_modules sq where sq.object_id = (SELECT object_id from managed.sys.objects Where type = 'P' and Name = 'usp_gen_data') Declare @Pos int SELECT @pos=CHARINDEX(CHAR(13)+CHAR(10),@script,7500) PRINT SUBSTRING(@Script,1,@Pos) PRINT SUBSTRING(@script,@pos,8000) The length of the Script is around 10,000 Characters and Since I am using print Statement which can hold only max of 8000. So I am

Invalid column name, on select-statement created columns

本小妞迷上赌 提交于 2020-01-07 09:31:58
问题 I have simplified my problem to the following select statement. select u.UserId, aVariable = cast((case when exists(select * from TblUser u where u.Disabled=1) then 1 else 0 end) as bit), from TblUser u where aVariable = 1 aVariable is not a column of a table, but just a column that gets a value in this select statement. Is there a way to do the above without getting the Invalid column name aVariable error? 回答1: select q.* from ( select u.UserId, cast((case when exists(select * from TblUser u

updating a sql 2005 database using text boxes in vb.net

南楼画角 提交于 2020-01-07 05:51:06
问题 I have a VB.Net form which allows the user to update the customer details such as name, contact no:, etc. So when the customer enters the new name for the customer name etc. the application should update the corresponding field in the existing entry that relates to the customer ID. Dim cn As New SqlConnection Dim cmd As New SqlCommand Dim adapter As New SqlDataAdapter Dim dt As New DataTable cn.ConnectionString = ("Data Source=NIMO-HP\SQLEXPRESS;Initial Catalog=FYP_db;Integrated Security=True

Update table Data without using while loop in sql server 2005

你离开我真会死。 提交于 2020-01-07 05:46:06
问题 in sql i have table data like below id type amount 1 type1 2000 2 type1 1000 3 type2 500 4 type3 3000 5 type1 2000 6 type2 500 7 type3 5000 8 type1 1000 and i want to get datas in select statement like below id type amount current 1 type1 2000 2000 2 type1 1000 1000 3 type2 500 500 4 type3 3000 3000 5 type1 2000 3000 6 type2 -500 0 7 type3 5000 2000 8 type1 -1000 4000 and so on that means each type must have its current total amount based on amount type and its need to be dont have while loop

How can I do server side pagination of results in SQL Server 2000?

主宰稳场 提交于 2020-01-07 04:57:27
问题 In SQL Server 2005, there is a feature called row_number() which makes pagination very simple. SELECT * FROM table WHERE row_number() between x and y Is there any SQL server way to do the same thing in SQL Server 2000? (Note: I don't have access to a unique sequential numbering for the query, i.e. something which would be a synonym for row_number()) 回答1: SELECT * FROM ( SELECT TOP (Y - X ) * FROM ( SELECT TOP Y * FROM mytable ORDER BY column ) q ORDER BY column DESC ) ORDER BY column 回答2: Not

SSMS crashes when opening Design Query Editor

試著忘記壹切 提交于 2020-01-07 04:46:42
问题 is there a fix for the crash in SQL-Server 2005 Management Studio when you try to open a design-query-editor with a sql-statementent preceding USE database; ? For example: USE DB1; SELECT * FROM Table1; If you mark SELECT * FROM Table1; , you can open the editor succesfully. If you mark both lines, SSMS will crash with a "Microsoft SQL Server Management Studio has stopped working"-Dialog(with the option to debug or close SSMS) and some additional information on this problem f.e.: Problem

SQL Server job activity (job failed but history records in job activity still showing 'running' status )

不打扰是莪最后的温柔 提交于 2020-01-07 03:06:23
问题 I am checking one SSIS job execution report, which shows me the below report: The most recent one succeeded, but when you take a look at ID:217583, it is still running and never finished (duration keeps increasing), and when I check the job activity in sql server agent, that execution should failed before, the reason why I said that was because the start time matched. Here is the job history in sql server agent : So I assume this job execution failed but for some mystery reason, it still