Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7023719
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:44:48+00:00 2026-05-27T23:44:48+00:00

This is my SQL: DECLARE @tbl_WhereClause AS TABLE ( SearchField VARCHAR(255), Operator VARCHAR(25), ConditionData

  • 0

This is my SQL:

DECLARE @tbl_WhereClause AS TABLE (
    SearchField VARCHAR(255),
    Operator VARCHAR(25),
    ConditionData VARCHAR(MAX),
    MatchCase BIT,
    TableName VARCHAR(MAX)   
)

DECLARE @WhereClause_XML XML
SET @WhereClause_XML = 
'<NewDataSet> 
  <param>
   <SearchField>EmployeeID</SearchField>
   <FilterCondition> >= </FilterCondition>
   <ConditionData>201</ConditionData>
   <MatchCase>0</MatchCase>
   <Table>Employee</Table>
 </param>
 <param>  
   <SearchField>DeptID</SearchField>
   <FilterCondition> = </FilterCondition>
   <ConditionData>AC01</ConditionData>
   <MatchCase>1</MatchCase>
   <Table>Department</Table>
 </param>
 <param>  
   <SearchField>Dob</SearchField>
   <FilterCondition> >= </FilterCondition>
   <ConditionData>20120104</ConditionData>
   <MatchCase>0</MatchCase>
   <Table>Employee</Table>
 </param>
</NewDataSet>'

INSERT INTO @tbl_WhereClause (SearchField, Operator, ConditionData,  MatchCase,TableName)
SELECT  A.B.value('(SearchField)[1]', 'VARCHAR(255)' ) SearchField,
    A.B.value('(FilterCondition)[1]', 'VARCHAR(25)' ) Operator,
    A.B.value('(ConditionData)[1]', 'VARCHAR(MAX)' ) ConditionData,
    A.B.value('(MatchCase)[1]', 'BIT' ) MatchCase,
    A.B.value('(Table)[1]', 'VARCHAR(MAX)' ) TableName
FROM    @WhereClause_XML.nodes('/NewDataSet/param') A(B)

SELECT * FROM @tbl_WhereClause

How can I join with the system table for each field to get the each field data type and show. please run the script and do the necessary changes in SQL. thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T23:44:48+00:00Added an answer on May 27, 2026 at 11:44 pm

    Try this to verify tables and columns, and to bring its types with their properties:

    DECLARE @tbl_WhereClause AS TABLE (
    SearchField VARCHAR(255),
    Operator VARCHAR(25),
    ConditionData VARCHAR(MAX),
    MatchCase BIT,
    TableName VARCHAR(MAX),
    Validity VARCHAR(100),
    ColumnType VARCHAR(128),
    ColumnPrecision INT,
    ColumnScale INT,
    ColumnNullable bit
    )
    
    DECLARE @WhereClause_XML XML
    SET @WhereClause_XML = '
    <NewDataSet>
    <param>
    <SearchField>EmployeeID</SearchField>
    <FilterCondition> >= </FilterCondition>
    <ConditionData>201</ConditionData>
    <MatchCase>0</MatchCase>
    <Table>Employee</Table>
    </param>
    <param>  
    <SearchField>DeptID</SearchField>
    <FilterCondition> = </FilterCondition>
    <ConditionData>AC01</ConditionData>
    <MatchCase>1</MatchCase>
    <Table>Department</Table>
    </param>
    <param>  
    <SearchField>Dob</SearchField>
    <FilterCondition> >= </FilterCondition>
    <ConditionData>20120104</ConditionData>
    <MatchCase>0</MatchCase>
    <Table>Employee</Table>
    </param>
    </NewDataSet>'
    
    INSERT INTO @tbl_WhereClause (SearchField, Operator, ConditionData,  MatchCase,TableName, Validity, ColumnType, ColumnPrecision, ColumnScale, ColumnNullable)
    SELECT  A.B.value('(SearchField)[1]', 'VARCHAR(255)' ) SearchField,
        A.B.value('(FilterCondition)[1]', 'VARCHAR(25)' ) Operator,
        A.B.value('(ConditionData)[1]', 'VARCHAR(MAX)' ) ConditionData,
        A.B.value('(MatchCase)[1]', 'BIT' ) MatchCase,
        A.B.value('(Table)[1]', 'VARCHAR(MAX)' ) TableName,
        CASE WHEN t.NAME+c.NAME IS NULL THEN 'invalid' ELSE 'valid' END ,
        ty.NAME,
        c.PRECISION,
        c.Scale,
        c.Is_Nullable
    FROM    @WhereClause_XML.nodes('/NewDataSet/param') A(B)
    LEFT JOIN sys.tables t ON t.name = A.B.value('(Table)[1]', 'VARCHAR(MAX)' )
    LEFT JOIN sys.COLUMNS c ON T.OBJECT_ID = c.OBJECT_ID AND c.name = A.B.value('(SearchField)[1]', 'VARCHAR(255)' )
    LEFT JOIN sys.types ty ON c.system_type_id = ty.system_type_id 
    
    SELECT * FROM @tbl_WhereClause
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got this t-sql snippet: DECLARE @db_name varchar(255); SET @db_name = 'MY_DATABASE'; -- assuming
This SQL Server 2005 T-SQL code: DECLARE @Test1 varchar; SET @Test1 = 'dog'; DECLARE
I have this SQL DECLARE @url varchar(100) SET @url = 'http://mysite.com/%' SELECT [UserSessionSequenceID] ,[SiteID]
I'm trying to execute this script through JDBC (it's SQL Server): DECLARE @var VARCHAR(10)
Running this code DECLARE @SQL VARCHAR(2500) = '''SELECT z.* from openrowset(''''SQLNCLI'''',''''Server=server;UID=user;PWD=pwd;'''', ''''SELECT distinct x.PackageName
Let's say I have this SQL query: declare @input varchar(20) select * from myTable
I have built a T-SQL query like this: DECLARE @search nvarchar(1000) = 'FORMSOF(INFLECTIONAL,hills) AND
I have this sql statement: CREATE TABLE [dbo].[User]( [UserId] [int] IDENTITY(1,1) NOT NULL, [FirstName]
Given this SQL: DECLARE @content XML SET @content = '<people> <person id=1 bimble=1> <firstname
in this SQL code DECLARE @n tinyint WHILE (@n > 0) BEGIN SELECT @n

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.