473,661 Members | 2,484 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Dynamic Select in MSSQL

6 New Member
Hi folks,
I have a problem migrating from Oracle to MSSQL the statement:
stmt2 := 'Select substr('||tabc| |',1,50) from '||tabn||'
OPEN cur2 FOR stmt2;

How can I to perform this dynamic select into MSQL ????

Thanks 4 your help
Sep 15 '06 #1
1 2434
agocurti
6 New Member
I partially solved with:

Exec ('select substring('+@ch vCol+',1,50) from ' + @chvTable + ......)

with

DECLARE @chvTable sysname, @chvCol sysname
Sep 19 '06 #2

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

Similar topics

3
8649
by: LineVoltageHalogen | last post by:
Greeting All, I have a stored proc that dynamically truncates all the tables in my databases. I use a cursor and some dynamic sql for this: ...... create cursor Loop through sysobjects and get all table names in my database. .... exec ('truncate table ' + @TableName)
9
6607
by: Rodusa | last post by:
I am trying to assign @sql variable to @total, where @sql is a sql statement stored on the database, however what I am getting is its string value and not its calcuation. Could anybody help? DECLARE my_cursor CURSOR FOR SELECT sqlstatement from Sn_SalesReport declare @sql varchar(255), @total varchar(20) OPEN my_cursor FETCH NEXT FROM my_cursor INTO @sql
15
5170
by: NickName | last post by:
Task: Create 100 or so stored procedure scripts similar to the convention of Generating Script from EM automatically. I thought of essentially two things of a) using sp_helptext to get the content of a sp; and b) using bcp to write such content to a (dynamic) file. What bugs me is really the curse of dynamic sql. process inside a cursor: ------------------------ exec master..xp_cmdshell 'bcp "exec sp_helptext '+@spName+'" queryout
1
8540
by: quadoc | last post by:
I've the following Select Statement that generates errors, could someone tells me why? :( SELECT TOP 20 * FROM tickets WHERE ticket_ID NOT IN (SELECT TOP 20 * FROM tickets ORDER BY ticket_ID DESC) ORDER BY ticket_ID DESC; Warning: mssql_query() : message: Only one expression can be specified in the select list when the subquery is not introduced with EXISTS. (severity 16) in c:\Inetpub\wwwroot\schoolProject\admin\show.php on line 437
7
3383
by: serge | last post by:
How can I run a single SP by asking multiple sales question either by using the logical operator AND for all the questions; or using the logical operator OR for all the questions. So it's always either AND or OR but never mixed together. We can use Northwind database for my question, it is very similar to the structure of the problem on the database I am working on. IF(SELECT OBJECT_ID('REPORT')) IS NOT NULL DROP TABLE REPORT_SELECTION
5
6892
by: Daniel Wetzler | last post by:
Dear MSSQL experts, I use MSSQL 2000 and encountered a strange problem wqhile I tried to use a select into statement . If I perform the command command below I get only one dataset which has the described properties. If I use the same statement in a select into statement (see the second select) I get several datasets with the described properties like I didn't use distinct
0
1311
by: intergroove | last post by:
Help. This has been bugging me for a couple of days now: I am writing a script to regularly transfer data from a MYSQL db to a MSSQL. Being new to MSSQL I'm a bit freaked out about the UNIQUEIDENTIFER (UI) system. I have to INSERT data to a table where I need the UI for items from 2 other tables. This negates my ability to use a JOIN. So I need to grab the UI from within PHP and the reference the variable in the query.
1
1340
by: David Costello | last post by:
Hello everyone, It would appear I'm trying to do something that's completely undocumented. I can't find anything of any use online to help me with this... I'm working on developing an MSSQL query editor for a bigger database program, for a university project. The project consists of around 50 or so tables. The query editor is meant to display a tabcontrol with a text box for query input on each tab, and a Datagridview, to display the...
3
6420
by: krzys | last post by:
I have 2 databases (with different user names and different passwords), and I need to join column_1 from table_A (on first database: database_I) on column_2 from table_B (on second database: database_II). How query should likes? I want to do this in php - where should I specify different user names and diffrent passwords for databases? <?php $dbhost="server_name\instance_name,port_number";
0
8432
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8856
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
7365
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6185
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5653
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4179
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4347
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2762
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1992
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.