Template Function

Oct 10, 2005

Hi,

Suppose I have a table something like:

name (VARCHAR(64)) age (INT) quotation (TEXT)
=================================================
Donald Trump 50 I am rich
Bugs Bunny 26 What's up doc
...

and a template string something like:

SET @template = 'My name is {name}, my age is {age}, and I always say
"{quotation}".'

I'd like to be able to dynamically replace the placeholders in the
template string with values extracted from the corresponding columns in
the table, so I'd get a set of results like:

'My name is Donald Trump, my age is 50, and I always say "I am rich".'

The best I've come up with so far is:

SET @Query = 'SELECT '''
+ REPLACE(REPLACE(@String, '{', '''+CONVERT(varchar,'),
'}', ')+''')
+ ''' FROM Table'
EXEC (@Query)

This converts the template string into a query string, casting
everything to a
varchar to allow numeric values to work. In this case it would be:

SELECT 'My name is '+CONVERT(varchar,name)+', my age is '
+CONVERT(varchar,age)+', and I always say "'
+CONVERT(varchar,quotation)+'".'

The problem with this is that if the length of a varchar is
unspecified, it defaults to 30, which truncates long string values.

Can anyone figure out a way round this, or perhaps an alternative
method entirely?

--
Oli

View 5 Replies


ADVERTISEMENT

Default Template For User Defined Function

Jan 6, 2006

How can I restore the original User Defined Function Template? I madean error and saved one of my UDFs as a template but would like theoriginal template restored?TIA

View 3 Replies View Related

Sp Template

Sep 4, 2006

Somehow I have saved an sp as a template - how do I delete it ?

View 4 Replies View Related

DTS Project Template Not Available?

Jan 19, 2006

I need to import data from a CSV file into a db I'm designing.  I figured I'd use DTS (which I understand now uses VS in the form of a 'Business Intelligence' (BI) project).  My problem is that my only choices for BI projects are:
Analysis Service Project, Import Analysis Services 9.0 Database, Integration Services Project, Report Server Project Wizard, Report Model Project, Report Server Project.
No "Data Transformation Project".
I have SQL Server 2005 Developer's Edition.  Might it be that DTS is not included in that version?
If I can't use DTS, what choices do I have?

View 2 Replies View Related

Database Template

Feb 14, 2001

Hi! I'm new to SQL Server 7 and I hope I could get some help. I'd like to duplicate an empty database and use the duplicate for the transactions. I want the empty database to somehow act like a template so, whenever I want to, I could create a new instance of it. Problem is I don't know if it is possible to do that on SQL server (it's possible in Access). If it is possible, I hope any of you could tell me how. Thanks.

View 1 Replies View Related

How Do I Run Logtemp.sql Template

Apr 5, 2000

Hello,

I'm having a hard time trying to figure out how to run the logtemp.sql script that is included with IIS4 for ODBC logging. Any help would be appreciated.

View 2 Replies View Related

Save As Template?

Jan 29, 2004

In Enterprise Manager when I bring up Trigger Properties there is an active button titled "Save as Template". But when I switch to an existing trigger the button is disabled. Oddly, the Help file for the dialog box doesn't even mention this button.

Anybody know what this does, how it works, or why it would be usefull? Any references to The Holy Book would be helpfull.

View 14 Replies View Related

TOP X Query In Xml Template

May 6, 2004

HI,

how can I specify the number of records that have to be sent back dynamically in an Xml Template?

I am currently busy developing a client-server application that pulls data from an Sql Server via Xml. If the client application has a bad connection to the server, the program has to get the data in small portions.

When I use:

SELECT TOP @amount *
FROM employees

I get the error: syntax near '@amount'.

The query fails as wel when I tried to use:

SET ROWCOUNT @amount

SELECT *
FROM employees

SET ROWCOUNT 0

This works fine in Sql analyser, but sql doesn't allow the integers to be parameters and casting them to int does not work either.

thanks for your help!

View 3 Replies View Related

Header Template

Mar 5, 2007

Hi all. How to make a template header for reports please? So that everytime I make a report, ill just call the template in the header.
Thanks.
-Ron-

View 3 Replies View Related

Template Explorer

Nov 7, 2007

Hi,
Is there any way to change path for template explorer? Default path for SQL templates is ..Application DataMicrosoftMicrosoft SQL Server90ToolsShellTemplatesSql. I have scripts & would like to share with my teammates. Is there any way to set this path to a common folder so that whenever anybody connects with their login to our TS server, they should be able to see these scripts in template explorer.

Thanks in advance
Sandesh

View 2 Replies View Related

Bad Proc Template

Jul 28, 2006

There is a base-installed template for a stored procedure called "Create Procedure with CURSOR OUT" which has this snippet:


EXEC <Schema_Name, sysname, Schema_Name>.<Procedure_Name, sysname, Procedure_Name> <@proc_cursor_name, , @sample_procedure_cursor> = <@variable_cursor_name, , @test_cursor_variable> OUTPUT

WHILE (@@FETCH_STATUS = 0)

BEGIN

FETCH NEXT FROM <@variable_cursor_name, , @test_cursor_variable>

PRINT 'put user defined code here'

END
But even after instantiating it - it doesn't work. The "FETCH_STATUS" must be seeded with a prior "FETCH" before it has any meaning. This leads me to ask: (1) how could such a widely circulated template have such a conspicuous error and (2) why doesn't TSQL have a looping mechanism that does not require such awkward FETCH "pre-seeding"?
p.s. How do I insert code into a forum post that is single-spaced, rather than duoble-spaced (like my ugly double-spaced snippet above)

View 1 Replies View Related

Using RS 2000 As A Template

Feb 22, 2007

I have created a template like report which is all working correctly. The report shows a order slip for all orders that are in a certain pick, and has a list of all products for each order. (so a list of products is printed for each order in the pick)

The question I have is, when the order is very long ie doesnt fit in 1 page, I need someway of the user easily knowing that there is more than 1 page... ie it should be Page 1 of 2... but in the whole report it may be Page 56 of 60.... is there a way of doing this??? or something similar...

I hope i have made myself clear... and would be VERY garteful for any ideas, im bit lost!...



Thanks

View 3 Replies View Related

Package Template (How Is It Different From....?)

Apr 10, 2008

I read the steps on creating a package template and using that template in future Projects.

My question is, how is doing Add -> New Item from the solution different from Add Existing Package from SSIS Packages. Other than the quicker navigation, I see no difference. So, is that it?

View 5 Replies View Related

Where Is Server Template

Jul 27, 2015

I have Visual Studio 2012 (Ultimate) installed (Update 4) with SSDT (version 11.1.50512.0),  I can see the template SQL Server Database Project, but where is the server-level project, SQL Server Project?

Previously, in Visual Studio 2008, I had a Category Database Projects with subcategories for SQL Server CLR, SQL Server 2000, SQL Server 2005 and SQL Server 2008.  Each of those had a SQL Server 200x Server Project template.These seem to be missing in Visual Studio 2012.

View 5 Replies View Related

SQL Database Template

Dec 5, 2005

Hi.  I'm running VS2005 and trying to use the SQL Database installed template (right-click my project in Solution Explorer / Add / New Item / SQL Database template ("An empty SQL database for local data") to create an MDF file per the "AbsoluteBeginner-Lesson08" video available on MSDN.  When I click "Add", I get an error stating that "Connections to SQL Server files require SQL Server Express to function properly.  Please verify the installation of the component or download from the URL: http://go.microsoft.com/fwlink/?LinkID=49251".  I'm running SQL 2000, SQL 2005 and SQL Express 2005 (all work and can be hit from Management Studio) on 2003 Server.  I'm assuming that it's because the Express instance is a named instance, not the default but I can't find any references.  Anybody else had this probelm?  Thanks.

View 1 Replies View Related

Template For Lookup

Apr 24, 2007

hi all,



i use quite some number of lookups for almost all of my fact tables ETL.

i was wondering if i can create a template or something similar so i can reuse the lookup instead of creating it again in each data flow for the fact table..



Thanks.

View 3 Replies View Related

Creating Report Template

Jan 16, 2007

HI
I want to create a report template in SQL Server 2005 Reporting Services.
The template will have a fixed header and footer.I want to use this template in all my reports.
How to do so?

View 2 Replies View Related

CREATE DATABASE From Template?

Apr 26, 2006

Hello,I need to be able to CREATE DATABASE by copying an existing
database.I would be doing this inside of a web app during an event.How do I set this up on SQL 2005 ?Thanks!Here's an article on how to do it in PostgreSQL http://www.enterprisedb.com/documentation/manage-ag-templatedbs.html

View 2 Replies View Related

Report Template With Totals??

Apr 19, 2007

Hello All,



Can someone tell me how to achieve this template of the report:

Initially when not expanded

+Item number

- - - - - -(these are summed values)

After expnading the fields(+)



-Item number

-item name

[ (details)

[ (details)

[ (details)

- - - -(summed values)



Right now, I can achive the second scenario (expanded one) but initially my report just comes up with

+Item number

and the second line (summed values) are not in there . Any sort of help will be appreciated.

Thanks,

Rashi

View 3 Replies View Related

CREATE TABLE Template

Jul 9, 2006

I accidentally altered the CREATE TABLE template from SQL Server Management Studio Express. Now I don't have the original. Could somebody please post CREATE TABLE template.

View 4 Replies View Related

Create New Database Based On A Template Using SMO

May 6, 2007

Hi All,
I'm working on a web application where the user needs to be able to create and name new databases that are identical in structure to other existing databases (that is, all tables, stored procedures, functions, indexes, etc.). This is so that they can create a new database for each client and need to be able to do this through the web application. Having hunted around a fair bit, I've established that SMO is capable of doing pretty much everything that I want. The only problem is that everything I do seems to be based on the actual SQL Server and associated databases rather than the ones I have created in the App_Data folder.
The relevant code (so far) is:Dim sqlServer As New Server()
With sqlServer.ConnectionContext
.ServerInstance = "(local)"
.Connect()
.Disconnect()
End With

For Each db As Database In sqlServer.Databases
ListView1.Items.Add(db.Name)
Next

Dim newDatabase As New Database(sqlServer, DbName.Text.ToString)
newDatabase.Create()
This does actaully create a new database, just not where I want it! Can anyone point me in the right direction as to how I can create a copy of a database in the App_Data folder?
Thanks & regards,
Paul

View 4 Replies View Related

Can I Use My Own Stored Procedure Template With SQL2005?

Oct 25, 2007

When I go to create a new stored procedure, function, etc. I get a default template... is there anyway to replace this template with one of my own? One that will already have the important information pre-populated (the stuff I always end up having to type in, like company name, etc.).

View 1 Replies View Related

A CAST That Appears To Use A Template. Is This Correct?

Feb 22, 2008

I need some feedback on how this sql is perfroming a cast. I have used CAST before, but I amlooking at a stored procedure, and the CAST looks slightly different. Usually when I do acast, it is of the form CAST(ColumnName,DataType) but this cast is slightly different as theyappear to be using some type of template to cast with. Here is the code. I will put line numbers in for reference.
 
1    CREATE TABLE #Groups2    (PartyId uniqueidentifier)3    INSERT INTO #Groups (PartyId)4    SELECT PartyId5    FROM ttg_sfGroupsByPartyId(@PartyId)67    IF (@PortalId = CAST('00000000-0000-0000-0000-000000000000' AS uniqueidentifier) AND88 @TabId = CAST('00000000-0000-0000-0000-000000000000' AS uniqueidentifier))0     BEGIN
Also just to let you know, the the values PartyId, and PortalId are GUIDS.
So, I guess my question is, are they using a kind of template to format the data? So look at lines7 and 8. Are they using some type of template to signal the compiler, that the data will be of thatformat and will be seperated by dash symbols?

View 2 Replies View Related

Template For SQL Server 7 Configuration Documentation

Sep 26, 2001

Does anyone have a template for storing all SQL Server 7 information.
Database, filegroup, drive, ...etc. Any help appreciated


Paul.

View 1 Replies View Related

BCP Template Using Quoted Text Qualifiers

Nov 2, 2005

I'm dumping data from a table via BCP and when BCPing them back in to another table, it errors out on numeric and date fields. I'd like to place quote marks on the text fields. How do I do this using BCP?

View 4 Replies View Related

How To Restore Default Trigger Template

May 24, 2004

I modified the trigger template in SQL Server Enterprise Manager.
How to restore default trigger template,like follow
--------------------------------------------------------
CREATE TRIGGER [TRIGGER NAME] ON [dbo].[tablename]
FOR INSERT, UPDATE, DELETE
AS
--------------------------------------------------
Does the information of trigger template save in a file ?
Anyone has idea ?

View 4 Replies View Related

SQL Server 2008 :: Shortcut Key For Template?

Sep 30, 2015

I created a template that I use all the time. Normally I just drag-n-drop from the Template Explorer menu, however I'm wondering if I can assign a shortcut key to have it open? I see you can assign stored procedures and other items, but I can't find where/if I can do this for a template.

View 2 Replies View Related

Where Is Report Server Project Template?

Feb 27, 2007

From file, new, project, I did not see Project types.
Where is Report server project template?
How to make it appear?

View 2 Replies View Related

Profiler Performance Trace Template

Jul 20, 2005

Greetings,I have been attempting to develop a useful and functional template fordatabase tracing/profiling that will enable me to collect metrics forperformance tuning. The database is used as an OLTP database as well asrunning reports. Below is a list of my trace properties and data columns.I would be interested to see other examples and strategies for the Profiler.thanxPerformanceExecution planSecurityAudit LoginAudit LogoutSessionsExisting ConnectionStored ProceduresRPC: CompletedTSQLSQL:Batch completedDATA COLUMNSEvent classtextdataapplication nameNTUsernameLoginNamesCPUreadwritedurationclient proc idSPIDStarttime

View 3 Replies View Related

Where Can I Get A C# CLI Assembly Template To Create A New Project With?

Dec 29, 2006

Does anyone know where I can download a C# CLI Assembly template?

In VS 2005 there are no defaults to create a C# SQL Assembly like the sample HelloWorld. Rather than modifying the Hello World, I'd like to get an original template for creating a new project just like the templates to create a new Windows project.

Thanks,

Chris

View 1 Replies View Related

Creating A Stored Proc From A Particular Template?

Mar 16, 2006

Hello,

I'm trying to get to grips with SQL Server 2005.

One of the things I want to do is provide members of my team with a stored procedure template that they can use which has special error handling code in it , etc

I found my way to the template explorer and created a new template that I want to use to create stored procedures in certain circumstances (but not ALL circumstances)

But now I can't figure out how to specify WHICH template to use when creating a stored procedure.

Like, when I click on the Programmability/Stored Procedures node and then right click and select New Stored Procedure... it just uses the Basic Template.. but I'd like to be able to elect to use my alternative template to create the stored proc.

So, what are the correct steps to follow? do i just double click my new template in Template Explorer? And then have to go Query/Specify Values for Template Parameters ? Or what?

If this is the way to do it then it seems very clunky really....

Thanks

View 1 Replies View Related

Change Location Of Template Files

Aug 8, 2006

In SQL2000, there's an option to change the location of the template folder. This allows me to create a customized set of templates on a network folder and have all the developers reference the centralized location. Can the same be done in SQL2005 and how would I go about doing so?

Thanks.

View 1 Replies View Related

Report Model Template Is Missing

Jul 26, 2007

I want to create a new report model project, however in VS Business intelligence Development Studio, I could find the report model template in the New project dialog box. Anyone coulf tell me how can I add the templeate? Thanks

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved