sql-server-2005

Is it possible to pass a table name into a stored proc and use it without the Exec Function?

我与影子孤独终老i 提交于 2020-01-04 14:06:01
问题 I would like to create a SP or UDF where I supply a table and column name as a parameter and it does something to that target. I'm using Sql Server 2005 Trivial Example of what I'm trying to accomplish: CREATE FUNCTION Example (@TableName AS VARCHAR(100)) RETURNS TABLE AS BEGIN SELECT * INTO #temp FROM @TableName RETURN #temp END The example is just something trivial to illustrate what I'm trying to accomplish in terms of passing the Table name as a parameter. Is this possible to do w/o

split select results (one column) into multiple columns

浪尽此生 提交于 2020-01-04 13:38:45
问题 I've been trying to work out how to accomplish this, but I think I just don't have the skills to know what to look for in the first place. I'm working with an existing system, and I cannot alter the database schema, nor can I dictate how the users enter data. I have to work with what we have. Currently, our user is putting stats data into one text field in a table. They are using a standard format of one stat per line, with text qualifiers to 'delimit' the details of the stat. i.e. <Category>

split select results (one column) into multiple columns

删除回忆录丶 提交于 2020-01-04 13:38:22
问题 I've been trying to work out how to accomplish this, but I think I just don't have the skills to know what to look for in the first place. I'm working with an existing system, and I cannot alter the database schema, nor can I dictate how the users enter data. I have to work with what we have. Currently, our user is putting stats data into one text field in a table. They are using a standard format of one stat per line, with text qualifiers to 'delimit' the details of the stat. i.e. <Category>

Random select is not always returning a single row

扶醉桌前 提交于 2020-01-04 13:11:27
问题 The intention of following (simplified) code fragment is to return one random row . Unfortunatly, when we run this fragment in the query analyzer, it returns between zero and three results. As our input table consists of exactly 5 rows with unique ID's and as we perform a select on this table where ID equals a random number, we are stumped that there would ever be more than one row returned. Note: among other things, we already tried casting the checksum result to an integer with no avail.

SSRS - broken/missing toggle images in html reports

筅森魡賤 提交于 2020-01-04 11:04:51
问题 SSRS version is SQL 2005 x64 sp2 on Windows 2003 x64 sp2 and IIS 6 Clients run IE 6 on a mixture of Win2k sp4 and WinXP sp3 reports are accessed through the standard SSRS html viewer As the title suggests my issue is that, in SSRS reports which use toggle buttons to control visibility of sections, the graphics for the toggle buttons will either not be shown or will be shown as broken links (with the standard IE missing image placeholder). In either case the toggling action continues to

SQL Server - Storing linebreaks in XML data type

独自空忆成欢 提交于 2020-01-04 10:53:26
问题 Is it possible to store non-alphanumeric characters (more specifically line break characters) in a XML data type? The code below illustrates my problem: declare @a xml declare @b nvarchar(max) set @b = '<Entry Attrib="1'+CHAR(13)+'2" />' print @b set @a=convert(xml,@b,1) set @b=convert(nvarchar, @a,1) print @b The output is: <Entry Attrib="1 2" /> <Entry Attrib="1 2"/> Is there any way I could keep the line break intact? My actual problem is to store the value in a table (rather than a local

SQL Server - Storing linebreaks in XML data type

扶醉桌前 提交于 2020-01-04 10:51:40
问题 Is it possible to store non-alphanumeric characters (more specifically line break characters) in a XML data type? The code below illustrates my problem: declare @a xml declare @b nvarchar(max) set @b = '<Entry Attrib="1'+CHAR(13)+'2" />' print @b set @a=convert(xml,@b,1) set @b=convert(nvarchar, @a,1) print @b The output is: <Entry Attrib="1 2" /> <Entry Attrib="1 2"/> Is there any way I could keep the line break intact? My actual problem is to store the value in a table (rather than a local

SQL - Is there a better way of passing a list of keys, for use in a where clause, into a Stored Procedure?

岁酱吖の 提交于 2020-01-04 10:16:36
问题 Here's the scenario; I have a list of CustomerIds (1, 2, 3) that have relating OrderIds . I have one Stored Procedure Delete_OrdersByCustomerIds , which deletes all the orders that are related to the CustomerIds specified. Currently, the way I do this is to concatenate the CustomerIds into a string, i.e. "1,2,3". I then pass this string through to my stored procedure and use the following function to create a Table of Int's that I can join on: CREATE FUNCTION [dbo].[iter$simple_intlist_to_tbl

SQL - Is there a better way of passing a list of keys, for use in a where clause, into a Stored Procedure?

左心房为你撑大大i 提交于 2020-01-04 10:12:18
问题 Here's the scenario; I have a list of CustomerIds (1, 2, 3) that have relating OrderIds . I have one Stored Procedure Delete_OrdersByCustomerIds , which deletes all the orders that are related to the CustomerIds specified. Currently, the way I do this is to concatenate the CustomerIds into a string, i.e. "1,2,3". I then pass this string through to my stored procedure and use the following function to create a Table of Int's that I can join on: CREATE FUNCTION [dbo].[iter$simple_intlist_to_tbl

SQL - Is there a better way of passing a list of keys, for use in a where clause, into a Stored Procedure?

两盒软妹~` 提交于 2020-01-04 10:12:12
问题 Here's the scenario; I have a list of CustomerIds (1, 2, 3) that have relating OrderIds . I have one Stored Procedure Delete_OrdersByCustomerIds , which deletes all the orders that are related to the CustomerIds specified. Currently, the way I do this is to concatenate the CustomerIds into a string, i.e. "1,2,3". I then pass this string through to my stored procedure and use the following function to create a Table of Int's that I can join on: CREATE FUNCTION [dbo].[iter$simple_intlist_to_tbl