473,408 Members | 1,960 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

T-SQL update dynamic tabels

hello

I am sure this is a simple Q, but I am not that familar with T-SQL so...
any how, I have dynamic tables taht I can fetch from this query:
SELECT NAME FROM SYSOBJECTS WHERE (NAME LIKE 'PW_OSSS%' OR NAME LIKE 'PW_OSPS%') AND TYPE = 'U';

and I need to run on them the Alter command
ALTER TABLE <dinamic table name that return from the select>MODIFY OSPS_IO_SUM NUMBER (18,6);
ALTER TABLE <dinamic table name that return from the select> MODIFY OSPS_IO_SUM NUMBER (18,6);
ALTER TABLE <dinamic table name that return from the select> MODIFY OSPS_IO_SUM NUMBER (18,6);

I would like to know how will I write the T-SQL transact (procedure) in order to be able to upgrade the column in the dynamic tables that return from the select query?

Thanks
Sep 23 '07 #1
2 2114
I will try to be more specific
this is the query that I run to have all the tables that I want to update

SELECT PWPR_PARTITION_NAME FROM PS_PWPR_PARTITION_RANGE
WHERE PWPR_TABLE_NAME LIKE 'PW_OSSS%'
OR PWPR_TABLE_NAME LIKE 'PW_OSPS%'

I want to run on each table that return and alter the table for example

ALTER TABLE PW_OSPS_PROC_STATISTICS_PU_T MODIFY OSPS_IO_SUM NUMBER (18,6);

how can I do it in one T-SQL command please
Sep 23 '07 #2
ck9663
2,878 Expert 2GB
I will try to be more specific
this is the query that I run to have all the tables that I want to update

SELECT PWPR_PARTITION_NAME FROM PS_PWPR_PARTITION_RANGE
WHERE PWPR_TABLE_NAME LIKE 'PW_OSSS%'
OR PWPR_TABLE_NAME LIKE 'PW_OSPS%'

I want to run on each table that return and alter the table for example

ALTER TABLE PW_OSPS_PROC_STATISTICS_PU_T MODIFY OSPS_IO_SUM NUMBER (18,6);

how can I do it in one T-SQL command please

you could use a CURSOR. fetch/loop on the entire result set. store the ALTER query to a variable to make the table name dynamic and do an EXEC(@yoursqlvariable)
Sep 23 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Steve | last post by:
Hi; I would like to read a list of tables from a temp table and then do a sql statement on each table name retrieved in a loop, ie: -- snip cursor loop where cursor contains a list of...
1
by: avinash | last post by:
hi myself avi i am developing one appliacaion in which i am using vb 6 as front end, adodb as database library and sql sever 7 as backend. i want to update one table for which i required data from...
0
by: terjelarsen | last post by:
Hi! I'm a newbee in TSQL, so I've a simple question (I think): I want to make a loop from the first row to the last row in one table. For each row I want to festch two fields @Customer_number...
1
by: The Bear | last post by:
does anyone know how to update a mysql database using C# or any other language for that matter. I keep getting the following error when I try to update: " Dynamic SQL generation is not supported...
1
by: Mark | last post by:
Hello, I have a database which contains approximately 30 reference tables. I've been looking at building a dynamic datagrid that is updateable, but have run into problems with the Cancel and...
1
by: Henke | last post by:
Hello, I have one ImageButton controls which I initialize in Page_Load and declare on class level. ImageButton save = new ImageButton(); save.ImageUrl = "save.gif" save.Click += new...
8
by: David Lozzi | last post by:
I'm fairly new to ASP.Net 2.0 SQLDatasource objects. It defaults using TSQL statments for the SELECT, INSERT, UPDATE, DELETE commands, which is great and it works. However, I've always been taught...
15
by: EDBrian | last post by:
My problem is this. Our clients create different fields they want to collect and we allow them build dynamic filters, reports etc... We run some TSQL to actually create the column and all works...
1
by: Gards035 | last post by:
I’m writing because I need help with a problem that has been frustrating me for about a week now and I am desperate for a solution. I recently built my first website using PHP and MySQL and am trying...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.